diff --git a/PO/LINGUAS b/PO/LINGUAS new file mode 100644 index 0000000..0a29054 --- /dev/null +++ b/PO/LINGUAS @@ -0,0 +1 @@ +de diff --git a/PO/POTFILES b/PO/POTFILES new file mode 100644 index 0000000..e2894a8 --- /dev/null +++ b/PO/POTFILES @@ -0,0 +1,4 @@ +../src/Controller/MainController.php +../src/Controller/SecurityController.php +../src/Controller/SetupController.php +../src/Kernel.php diff --git a/PO/POTFILES.webroot b/PO/POTFILES.webroot new file mode 100644 index 0000000..2ef3a3a --- /dev/null +++ b/PO/POTFILES.webroot @@ -0,0 +1,10 @@ +../src/MyDevel/Webroot/Controller/WebrootController.php +../src/MyDevel/Webroot/Controller/WebrootSetupController.php +../src/MyDevel/Webroot/Entity/WebrootFile.php +../src/MyDevel/Webroot/Entity/WebrootFilePermission.php +../src/MyDevel/Webroot/Entity/WebrootRole.php +../src/MyDevel/Webroot/Entity/WebrootUser.php +../src/MyDevel/Webroot/Repository/WebrootFilePermissionRepository.php +../src/MyDevel/Webroot/Repository/WebrootFileRepository.php +../src/MyDevel/Webroot/Repository/WebrootRoleRepository.php +../src/MyDevel/Webroot/Repository/WebrootUserRepository.php diff --git a/PO/PTOFILES b/PO/PTOFILES new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/PO/PTOFILES @@ -0,0 +1 @@ + diff --git a/PO/compilemessages b/PO/compilemessages new file mode 100644 index 0000000..4766057 --- /dev/null +++ b/PO/compilemessages @@ -0,0 +1,22 @@ +#!/bin/sh + +SELF="$(realpath "$0")" +PO_DIR="$(dirname "$SELF")" +PROJECT_ROOT="$(dirname "$PO_DIR")" + +cd "$PO_DIR" + +for i in `cat LINGUAS`; do + msgdir="$PROJECT_ROOT/translations/$i/LC_MESSAGES"; + if [ ! -d "$msgdir" ]; then + mkdir -p "$msgdir" + fi + + if [ -f $i.po ]; then + msgfmt -o "$msgdir/messages.mo" $i.po + fi + if [ -f webroot/$i.po ]; then + msgfmt -o "$msgdir/mydevel.webroot.mo" "webroot/$i.po" + fi +done + diff --git a/PO/de.po b/PO/de.po new file mode 100644 index 0000000..4ee1245 --- /dev/null +++ b/PO/de.po @@ -0,0 +1,18 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-11-26 20:44+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" diff --git a/PO/messages.pot b/PO/messages.pot new file mode 100644 index 0000000..4ee1245 --- /dev/null +++ b/PO/messages.pot @@ -0,0 +1,18 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-11-26 20:44+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" diff --git a/PO/mkpotfiles.sh b/PO/mkpotfiles.sh new file mode 100644 index 0000000..738b6f3 --- /dev/null +++ b/PO/mkpotfiles.sh @@ -0,0 +1,61 @@ +#!/bin/sh + +SELF="$(realpath "$0")" +PODIR="$(dirname "$SELF")" +PROJECT_ROOT="$(dirname "$PODIR")" + +cd "$PODIR" + +echo "Creating POTFILES" +rm -v POTFILES + +for i in $(find ../src | grep '\.php' | grep -v '\.\./src/MyDevel'); do + echo $i >> POTFILES +done +if [ -f messages.pot ]; then + JOIN="--join-existing" +else + JOIN="" +fi +echo "extracting messages" + +xgettext -f POTFILES -d messages -L PHP $JOIN --force-po -o messages.pot +if [ -z "$JOIN" ]; then + sed -i s/charset=CHARSET/charset=UTF-8/g messages.pot +fi + +for i in `cat LINGUAS`; do + if [ ! -f $i.po ]; then + cp messages.pot $i.po + else + msgmerge $i.po messages.pot + fi +done + +echo "Creating POTFILES.webroot" +rm -v POTFILES.webroot +for i in $(find ../src/MyDevel/Webroot | grep '\.php'); do + echo $i >> POTFILES.webroot +done + +if [ ! -d webroot ]; then + mkdir -v webroot +fi + +if [ -f webroot/messages.pot ]; then + JOIN="--join-existing" +else + JOIN="" +fi +xgettext -d mydevel.webroot -f POTFILES.webroot -L PHP $JOIN --force-po -o webroot/messages.pot +if [ -z "$JOIN" ]; then + sed -i s/charset=CHARSET/charset=UTF-8/g webroot/messages.pot +fi +for i in `cat LINGUAS`; do + if [ ! -f webroot/$i.po ]; then + cp webroot/messages.pot webroot/$i.po + else + msgmerge webroot/$i.po webroot/messages.pot + fi +done + diff --git a/PO/webroot/de.po b/PO/webroot/de.po new file mode 100644 index 0000000..4ee1245 --- /dev/null +++ b/PO/webroot/de.po @@ -0,0 +1,18 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-11-26 20:44+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" diff --git a/PO/webroot/messages.pot b/PO/webroot/messages.pot new file mode 100644 index 0000000..4ee1245 --- /dev/null +++ b/PO/webroot/messages.pot @@ -0,0 +1,18 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-11-26 20:44+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" diff --git a/composer.json b/composer.json index 0316fbf..c3ee750 100644 --- a/composer.json +++ b/composer.json @@ -55,9 +55,7 @@ }, "autoload": { "psr-4": { - "MyDevel\\": "src/MyDevel/", "App\\": "src/" - } }, "autoload-dev": { diff --git a/config/services.yaml b/config/services.yaml index 8d6e92e..b66817b 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -15,18 +15,6 @@ services: # this creates a service per class whose id is the fully-qualified class name - MyDevel\: - resource: '../src/MyDevel/' - - #exclude: - #- '../src/MyDevel/Webroot/Entity/' - #MyDevel\Webroot\Controller\WebrootSetupController: - # abstract: true - # class: WebrootSetupController - # autowire: true - # arguments: ['%kernel.project_dir%'] - - App\: resource: '../src/' exclude: diff --git a/migrations/Version20241126043446.php b/migrations/Version20241126043446.php deleted file mode 100644 index 27ce3c7..0000000 --- a/migrations/Version20241126043446.php +++ /dev/null @@ -1,43 +0,0 @@ -addSql('DROP TABLE mydevel_webroot_file'); - $this->addSql('DROP TABLE mydevel_webroot_file_permission'); - $this->addSql('DROP TABLE mydevel_webroot_role'); - $this->addSql('DROP TABLE mydevel_webroot_user'); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('CREATE TABLE mydevel_webroot_file (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, owner_id INTEGER NOT NULL, url CLOB NOT NULL COLLATE "BINARY", abspath CLOB NOT NULL COLLATE "BINARY", CONSTRAINT FK_A7B135127E3C61F9 FOREIGN KEY (owner_id) REFERENCES mydevel_webroot_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION NOT DEFERRABLE INITIALLY IMMEDIATE)'); - $this->addSql('CREATE UNIQUE INDEX UNIQ_A7B135127E3C61F9 ON mydevel_webroot_file (owner_id)'); - $this->addSql('CREATE TABLE mydevel_webroot_file_permission (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, role_id INTEGER NOT NULL, webroot_file_id INTEGER NOT NULL, is_readable BOOLEAN DEFAULT 1 NOT NULL, is_writeable BOOLEAN DEFAULT 0 NOT NULL, is_deleteable BOOLEAN DEFAULT 0 NOT NULL, CONSTRAINT FK_4D56CEFD60322AC FOREIGN KEY (role_id) REFERENCES mydevel_webroot_role (id) ON UPDATE NO ACTION ON DELETE NO ACTION NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_4D56CEF2800AFC9 FOREIGN KEY (webroot_file_id) REFERENCES mydevel_webroot_file (id) ON UPDATE NO ACTION ON DELETE NO ACTION NOT DEFERRABLE INITIALLY IMMEDIATE)'); - $this->addSql('CREATE INDEX IDX_4D56CEF2800AFC9 ON mydevel_webroot_file_permission (webroot_file_id)'); - $this->addSql('CREATE UNIQUE INDEX UNIQ_4D56CEFD60322AC ON mydevel_webroot_file_permission (role_id)'); - $this->addSql('CREATE TABLE mydevel_webroot_role (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, role VARCHAR(255) NOT NULL COLLATE "BINARY", name VARCHAR(255) NOT NULL COLLATE "BINARY", description VARCHAR(1023) DEFAULT NULL COLLATE "BINARY")'); - $this->addSql('CREATE TABLE mydevel_webroot_user (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, username VARCHAR(180) NOT NULL COLLATE "BINARY", roles CLOB NOT NULL COLLATE "BINARY" --(DC2Type:json) - , password VARCHAR(255) NOT NULL COLLATE "BINARY", email VARCHAR(255) NOT NULL COLLATE "BINARY")'); - $this->addSql('CREATE UNIQUE INDEX UNIQ_IDENTIFIER_USERNAME ON mydevel_webroot_user (username)'); - $this->addSql('CREATE UNIQUE INDEX UNIQ_A6BDD54BE7927C74 ON mydevel_webroot_user (email)'); - } -} diff --git a/migrations/Version20241126013626.php b/migrations/Version20241126213642.php similarity index 95% rename from migrations/Version20241126013626.php rename to migrations/Version20241126213642.php index c373fdc..08ebc8d 100644 --- a/migrations/Version20241126013626.php +++ b/migrations/Version20241126213642.php @@ -10,7 +10,7 @@ use Doctrine\Migrations\AbstractMigration; /** * Auto-generated Migration: Please modify to your needs! */ -final class Version20241126013626 extends AbstractMigration +final class Version20241126213642 extends AbstractMigration { public function getDescription(): string { @@ -25,6 +25,7 @@ final class Version20241126013626 extends AbstractMigration owner_id INTEGER NOT NULL, url CLOB NOT NULL, abspath CLOB NOT NULL, + description CLOB DEFAULT NULL, CONSTRAINT FK_A7B135127E3C61F9 FOREIGN KEY (owner_id) REFERENCES mydevel_webroot_user (id) NOT DEFERRABLE INITIALLY IMMEDIATE )'); $this->addSql('CREATE UNIQUE INDEX UNIQ_A7B135127E3C61F9 ON mydevel_webroot_file (owner_id)'); @@ -52,7 +53,8 @@ final class Version20241126013626 extends AbstractMigration roles CLOB NOT NULL --(DC2Type:json) , password VARCHAR(255) NOT NULL, - email VARCHAR(255) NOT NULL + email VARCHAR(255) NOT NULL, + is_admin BOOLEAN DEFAULT 0 NOT NULL )'); $this->addSql('CREATE UNIQUE INDEX UNIQ_A6BDD54BE7927C74 ON mydevel_webroot_user (email)'); $this->addSql('CREATE UNIQUE INDEX UNIQ_IDENTIFIER_USERNAME ON mydevel_webroot_user (username)'); diff --git a/src/Controller/MainController.php b/src/Controller/MainController.php index 809708c..1fe5a39 100644 --- a/src/Controller/MainController.php +++ b/src/Controller/MainController.php @@ -15,8 +15,10 @@ class MainController extends AbstractController //WebrootMainController { $project_root = $kernel->getProjectDir(); - if (!file_exists(join(DIRECTORY_SEPARATOR,[$project_root,'.env.local']))) { - return $this->redirect('/setup'); + $dotenvlocal_file = join(DIRECTORY_SEPARATOR,[$project_root,'.env.local']); + + if (!file_exists($dotenvlocal_file)) { + return $this->redirectToRoute('webroot.setup'); } return $this->render('main/index.html.twig', [ diff --git a/src/Controller/SetupController.php b/src/Controller/SetupController.php index e41b5f2..ffc5032 100644 --- a/src/Controller/SetupController.php +++ b/src/Controller/SetupController.php @@ -4,15 +4,200 @@ namespace App\Controller; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Attribute\Route; +use Symfony\Component\Form\Extension\Core\Type as FormType; +use Symfony\Component\Dotenv\Dotenv; +use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface; +use Doctrine\ORM\EntityManagerInterface; -use MyDevel\Webroot\Controller\WebrootSetupController; +use App\Controller\WebrootSetupController; +use App\Entity\WebrootUser; +use App\Entity\WebrootRole; class SetupController extends WebrootSetupController { + #[Route('/setup',name:'webroot.setup.initial')] + public function initialSetup(Request $request, + EntityManagerInterface $em, + UserPasswordHasherInterface $passwd_hasher): Response + { + $dotenv_file = join(DIRECTORY_SEPARATOR,[$this->getProjectDir(),".env"]); + $dotenvlocal_file = join(DIRECTORY_SEPARATOR,[$this->getProjectDir(),".env.local"]); + $errors = array(); + if (!file_exists($dotenv_file)) { + $file = fopen($dotenv_file, "w", false); + fclose($file); + } + + $form = $this->createFormBuilder() + ->add('language',FormType\TextType::class,) + ->add('site_name',FormType\TextType::class,[ + "mapped"=>false, + "label" => "Site name"]) + ->add('site_rootdir',FormType\TextType::class,[ + "mapped"=>false, + "label" => "Site Root Directory"]) + ->add('site_email',FormType\EmailType::class,[ + "mapped"=>false, + "label" => "Contact email"]) + ->add('user_username',FormType\TextType::class,[ + "mapped"=>false, + "label"=>"Username"]) + ->add('user_email',FormType\EmailType::class,[ + "mapped"=>false, + "label"=> "Email address"]) + ->add("user_password0", FormType\PasswordType::class,[ + "mapped"=>false, + "label"=>"Password"]) + ->add("user_password1",FormType\PasswordType::class,[ + "mapped"=>false, + "label"=>"Confirm Password"]) + ->add('db_backend',FormType\ChoiceType::class,[ + "mapped" => false, + "label" => "Database Backend", + "choices" => [ + "sqlite" => "SQLite3", + "mysql" => "MySQL/MariaDB", + "postgresql" => "PostgreSQL", + ]]) + ->add('db_database',FormType\TextType::class,[ + "mapped"=>false, + "label"=>"Database"]) + ->add('db_host', FormType\TextType::class,[ + "mapped"=>false, + "label"=>"Host"]) + ->add('db_port', FormType\IntegerType::class,[ + "mapped"=>false, + "label"=>"Port"]) + ->add('db_user',FormType\TextType::class,[ + "mapped"=>false, + "label"=>"User"]) + ->add('db_password',FormType\TextType::class,[ + "mapped"=>false, + "label"=>"Password"]) + ->add('email_backend', FormType\ChoiceType::class, [ + "mapped"=>false, + "label" => "Email Backend", + "choices"=> [ + "none", "None", + "smtp", "SMTP", + "sendmail","Sendmail", + "native","Naitve", + ]]) + ->add('email_path',FormType\TextType::class,[ + "mapped"=>false, + "label"=>"Email Path"]) + ->add('email_user',FormType\TextType::class,[ + "mapped"=>false, + "label"=>"User"]) + ->add('email_password', FormType\PasswordType::class,[ + "mapped"=>false, + "label"=> "Password"]) + ->add('email_host',FormType\TextType::class,[ + "mapped"=>false, + "label"=>"SMTP Host"]) + ->add('email_port',FormType\TextType::class,[ + "mapped"=>false, + "label"=>"SMTP Port"]) + ->add('email_address', FormType\EmailType::class,[ + "mapped"=>false, + "label"=>"Sender address"]) + ->add('submit', FormType\SubmitType::class) + ->getForm(); + + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $password0 = $form.get('user_password0')->getData(); + $password1 = $form.get('user_password1')->get_data(); + $errors[] = "Passwords dont match"; + + //if passwords don't match rerender form. + return $this->render("setup/initial-setup.html.twig",[ + "error" => $errors, + "form" => $form]); + + + $dotevnlocal = join(DIRECTORY_SEPARATOR,[$this->getProjectDir(),'.env.local']); + $file = fopen($dotevnlocal,"w"); + + $language=$form->get('language')->getNormData(); + if ($language || strlen($language) > 1) { + fwrite($file,"LANG=\"" . $language . "\"\n"); + } + + fwrite($file,"SITE_NAME=\"" . $form->get("site_name")->getNormData() . "\"\n"); + fwrite($file,"SITE_EMAIL=\"". $form->get('site_email')->getNormData() . "\"\n"); + + $db_backend=$form->get('db_backend')->getNormData(); + if ($db_backend === "sqlite") { + fwrite("DATABASE_URL=\"sqlite://" . $form.get('db_database') . "\"\n"); + } elseif ($db_backend === "mysql") { + fwrite("DATABASE_URL=\"msysql://" + . urlencode($form.get('db_user')->getNormData()) + . ":" . urlencode($form.get('db_password')->getNormData()) + . "@" . urlencode($form.get('db_host')->getNormData()) + . ":" . $form.get('db_port')->getNormData() + . "/" . urlencode($form.get('db_database')->getNormData()) + . "?charset=utf8mb4\"\n"); + } elseif ($db_backend === "postgresql") { + fwrite("DATABASE_URL=\"postgresql://" + . urlencode($form->get('db_user')->getNormData()) + . ":" . urlencode($form->get('db_password')->getNormData()) + . "@" . urlencode($form->get('db_host')->getNormData()) + . ":" . $form->get('db_port')->getNormData() + . "/" . urlencode($form.get('db_database')->getNormData()) + . "?charset=utf8"); + } + fclose($file); + (new Dotenv())->loadEnv(join(DIRECTORY_SEPARATOR,[$this->getProjectDir(),".env"])); + try { + $migration_message = $this->runMakeMigration(); + $migrate_message = $this->runMigrate(); + + $user = new WebrootUser(); + $user->setAdmin(true); + $user->setUsername($form->get('user_username')->getNormData()); + $user->setRoles(["ROLE_SUPERADMIN","ROLE_ADMIN","ROLE_USER"]); + $user->setEmail($form->get("user_email")->getNormData()); + $user->set_password($passwd_hasher->hashPassword($user, $password0)); + $em->persist($user); + + foreach($this->getInitialRoles() as $roledata) { + $role = new WebrootRole(); + $role->setRole($roledata["role"]); + $role->setName($roledata["name"]); + $role->setDescription($roledata["description"]); + $em->persist($role); + } + return redirectToRoute("app_login"); + } catch (\Exception $ex) { + unlink($dotevnlocal); + $errors[] = $ex->getMessage(); + } finally { + + } + + } + + return $this->render('setup/initial-setup.html.twig', [ + "form" => $form, + "errors" => $errors + ]); + } + #[Route('/setup', name: 'webroot.setup')] public function index(): Response { + if (!$this->isInstalled()) { + return redirectToRoute('webroot.setup.initial'); + } + + if (!$this->userIsLoggedInAsAdmin()) { + return redirectToRoute("app_login"); + } + return $this->render('setup/controller.html.twig', [ 'controller_name' => "WebrootController", 'function' => __FUNCTION__, diff --git a/src/MyDevel/Webroot/Controller/WebrootController.php b/src/Controller/WebrootController.php similarity index 85% rename from src/MyDevel/Webroot/Controller/WebrootController.php rename to src/Controller/WebrootController.php index 215a8bf..f541de3 100644 --- a/src/MyDevel/Webroot/Controller/WebrootController.php +++ b/src/Controller/WebrootController.php @@ -1,6 +1,6 @@ hasAdministrator(); } - /** - * @brief Check if there is a *.setupkey*-file in the project root. - * - * @note This file will be deleted after the initial setup! - * - * @return bool `true` if there is a *.setupkey* file int the project - * root directory. - */ - protected function hasSetupKey(): bool - { - return file_exists(join(DIRECTORY_SEPARATOR,[$this->project_dir,".setupkey"])); - } - - /** - * @Brief Get the actual setup key from file. - * @return string|null Returns `null` when there is no `.setupkey` file - * located in prject root else the first line of the file. - */ - protected function getSetupKey(): ?string - { - if (!$this->hasSetupKey()) { - return null; - } - $file = fopen($this->project_dir,".setupkey"); - $str = fread($file, 4096); - fclose($file); - $pos = strpos($str,"\r\n",0); - if (!$pos) { - $pos = strpos($str,"\n",0); - } - if ($pos) { - $key=substr(string,0,pos); - } else { - $key=$str; - } - return key; - } - /** * @brief Check if user is logged in for setup. * @return bool Returns `true` if user is logged in and is allowed to view * the setup pages. */ - public function isLoggedIn(): bool + public function userIsLoggedInAsAdmin(): bool { $user = $this->getUser(); if ($user && $user->isAdmin()) { return true; } - - $has_setup_key = $this->hasSetupKey(); - $has_administrator = $this->hasAdministrator(); - if (!$has_administrator && !$has_setup_key) { - return true; - } - - if ($has_setup_key && isset($_COOKIE["mydevel_webroot_sk"])) { - return (filter_input(INPUT_COOKIE, "mydevel_webroot_sk") === $this->getSetupKey()); - } - + return false; } @@ -132,33 +84,6 @@ abstract class WebrootSetupController extends AbstractController && file_exists(join(DIRECTORY_SEPARATOR,[$this->project_dir,".env.local"]))); } - /** - * @brief Check if the key marches the one from file. - * - * @param string $key The key to check. - * - * @return bool|null Returns `null` if there is no *.setupkey* file present, - * `true` on match and false if the key does not match. - */ - protected function checkSetupKey(string $key): ?bool - { - if (!$this->hasSetupKey()) { - return null; - } - - $file_key = $this->getSetupKey(); - if ($key === $file_key) { - $cookie_domain = getenv("WEBROOT_HOST"); - if (!$cookie_domain || !strlen("WEBROOT_HOST")) { - $request = $this->getRequest(); - $cookie_domain = $request->getHost(); - setcookie("mydevel_webroot_sk",$file_key,0,"/",$cookie_domain,1,0); - return true; - } - } - return false; - } - /** * * @return string @@ -175,10 +100,15 @@ abstract class WebrootSetupController extends AbstractController ]); $output = new BufferedOutput(); - $application->run($input,$output); + $errc =$application->run($input,$output); + $content=$output->fetch(); + if ($errc) { + throw new \Exception("make:migration failed!"); + } + return $content; } @@ -196,10 +126,23 @@ abstract class WebrootSetupController extends AbstractController "--no-interaction" => true, ]); $output = new BufferedOutput(); - $application->run($input,$output); + $ercode = $application->run($input,$output); + if ($errcode) { + throw new \Excpetion("runMigrate failed!"); + } $content = $output->fetch(); return $content; } + + public function getInitialRoles(): array + { + return [ + ["role"=>"ROLE_SUPERADMIN","name"=>"Super Administrator","description"=>"Super Administrator with all rights, always!"], + ["role"=>"ROLE_ADMIN","name"=>"Administrator","description"=>"Role with administrative rights."], + ["role"=>"ROLE_USER","name"=>"Common User","description"=>"Common user rights."], + ["role"=>"ROLE_PUBLIC","name"=>"Public Access","description"=>"Role for public access."], + ]; + } } diff --git a/src/MyDevel/Webroot/Entity/WebrootFile.php b/src/Entity/WebrootFile.php similarity index 87% rename from src/MyDevel/Webroot/Entity/WebrootFile.php rename to src/Entity/WebrootFile.php index a844b2c..f3d469d 100644 --- a/src/MyDevel/Webroot/Entity/WebrootFile.php +++ b/src/Entity/WebrootFile.php @@ -1,6 +1,6 @@ @@ -33,6 +35,7 @@ class WebrootFile #[ORM\JoinColumn(nullable: false)] private ?WebrootUser $owner = null; + public function __construct() { $this->permissions = new ArrayCollection(); @@ -67,6 +70,18 @@ class WebrootFile return $this; } + public function getDescription(): ?string + { + return $this->description; + } + + public function setDescription(?string $description): static + { + $this->description = $description; + + return $this; + } + /** * @return Collection */ diff --git a/src/MyDevel/Webroot/Entity/WebrootFilePermission.php b/src/Entity/WebrootFilePermission.php similarity index 98% rename from src/MyDevel/Webroot/Entity/WebrootFilePermission.php rename to src/Entity/WebrootFilePermission.php index 9ed5491..49b6e69 100644 --- a/src/MyDevel/Webroot/Entity/WebrootFilePermission.php +++ b/src/Entity/WebrootFilePermission.php @@ -1,6 +1,6 @@ + {{ form_start(form) }} + {{ form_widget(form) }} + {{ form_end(form) }} +
+{% endblock %} diff --git a/templates/webroot/de.directory.html.twig b/templates/webroot/de.directory.html.twig new file mode 100644 index 0000000..2c9ed5e --- /dev/null +++ b/templates/webroot/de.directory.html.twig @@ -0,0 +1,59 @@ +{% extends 'base.html.twig' %} + +{% block body %} +

Index für {{ url_path }}

+
+ {% if create_dir %} + + + + + + {% endif %} + {% if upload_file %} + + + + + + {% endif %} +
+ + + + + + + + + + + {% if parent_url %} + + + + + + + + + {% endif %} + {% for entry in dir_entries %} + + + + + + + + + {% endfor %} + +
[icon]NameGrößeZuletzt geändertBeschreibung

[icon]Zurück---icon
{% if entry.icon %}{{ entry.icon_alt }}{% endif %}{{ entry.name }}{{ entry.display_size }}{{ entry.last_modified }}{{ entry.description }} + {% if entry.delete %} + + {% else %} + + {% endif %} +

+{% endblock %} diff --git a/templates/webroot/directory.html.twig b/templates/webroot/directory.html.twig new file mode 100644 index 0000000..dad5a86 --- /dev/null +++ b/templates/webroot/directory.html.twig @@ -0,0 +1,59 @@ +{% extends 'base.html.twig' %} + +{% block body %} +

Index for {{ url_path }}

+
+ {% if create_dir %} + + + + + + {% endif %} + {% if upload_file %} + + + + + + {% endif %} +
+ + + + + + + + + + {% if parent_url %} + + + + + + + + + {% endif %} + {% for entry in dir_entries %} + + + + + + + + + {% endfor %} + +
[icon]SizeLast changedDescription

[icon]Zurück---icon
{% if entry.icon %}{{ entry.icon_alt }}{% endif %}{{ entry.name }}{{ entry.display_size }}{{ entry.last_modified }}{{ entry.description }} + {% if entry.delete %} + + {% else %} + + {% endif %} +

+{% endblock %} + diff --git a/translations/de/LC_MESSAGES/messages.mo b/translations/de/LC_MESSAGES/messages.mo new file mode 100644 index 0000000..6c5906d Binary files /dev/null and b/translations/de/LC_MESSAGES/messages.mo differ diff --git a/translations/de/LC_MESSAGES/mydevel.webroot.mo b/translations/de/LC_MESSAGES/mydevel.webroot.mo new file mode 100644 index 0000000..6c5906d Binary files /dev/null and b/translations/de/LC_MESSAGES/mydevel.webroot.mo differ