multi user

This commit is contained in:
2024-10-26 12:08:33 +02:00
parent ecfb7d82d4
commit b85d03f78c
26 changed files with 1310 additions and 240 deletions

View File

@ -53,22 +53,14 @@ class AppInitCommand extends Command
$output->writeln('APP = Default Data');
// Création du compte admin si non existant
$this->insertUser("admin",$this->container->getParameter('appInitpwdadmin'),$this->appname,"Admin",$this->appmailnoreply,['ROLE_ADMIN'],"admin.jpg");
// Init Media
//$this->initMedia();
// Création d'une catégory par défaut
$this->insertCategory(-100,1,"Illustrations");
// colorbgbody = Couleur des fonds de page
$this->insertConfig(
1, // order
false, // customizable
"site", // category
"appname", // id
"Titre de votre site", // title
"", // value
$this->appname, // value
"string", // type,
true, // visible
true, // changeable
@ -79,10 +71,11 @@ class AppInitCommand extends Command
$this->insertConfig(
2, // order
true, // customizable
"site", // category
"appsubname", // id
"Sous-titre de votre site", // title
"", // value
"Portefolio", // value
"string", // type,
true, // visible
true, // changeable
@ -93,6 +86,7 @@ class AppInitCommand extends Command
$this->insertConfig(
3, // order
true, // customizable
"site", // category
"appdescription", // id
"Description de votre site", // title
@ -107,6 +101,7 @@ class AppInitCommand extends Command
$this->insertConfig(
4, // order
false, // customizable
"site", // category
"appthumbwidth", // id
"Largeur des miniatures", // title
@ -121,6 +116,7 @@ class AppInitCommand extends Command
$this->insertConfig(
5, // order
false, // customizable
"site", // category
"appthumbheight", // id
"Hauteur des miniatures", // title
@ -135,6 +131,7 @@ class AppInitCommand extends Command
$this->insertConfig(
6, // order
false, // customizable
"site", // category
"appthumbfilter", // id
"Filtre sur les miniatures", // title
@ -149,7 +146,8 @@ class AppInitCommand extends Command
$this->insertConfig(
7, // order
"site", // category
false, // customizable
"false", // category
"appthumbfiltergrayscale", // id
"Filtre grayscale sur les miniatures", // title
"100", // value
@ -163,6 +161,7 @@ class AppInitCommand extends Command
$this->insertConfig(
8, // order
false, // customizable
"site", // category
"appthumbfilteropacity", // id
"Filtre opacity sur les miniatures", // title
@ -177,6 +176,7 @@ class AppInitCommand extends Command
$this->insertConfig(
9, // order
false, // customizable
"site", // category
"appthumbfiltersepia", // id
"Filtre sepia sur les miniatures", // title
@ -192,6 +192,7 @@ class AppInitCommand extends Command
$this->insertConfig(
10, // order
false, // customizable
"site", // category
"appmaxthumbwidth", // id
"Largeur maximum de la grille des thumbs", // title
@ -207,6 +208,7 @@ class AppInitCommand extends Command
// colorbgbody = Couleur des fonds de page
$this->insertConfig(
1, // order
false, // customizable
"colorbgbody", // category
"colorbgbodydark", // id
"Couleur de fond fonçée", // title
@ -221,6 +223,7 @@ class AppInitCommand extends Command
$this->insertConfig(
2, // order
false, // customizable
"colorbgbody", // category
"colorbgbodylight", // id
"Couleur de fond claire", // title
@ -236,6 +239,7 @@ class AppInitCommand extends Command
// colorfttitle = Couleur des fontes titre
$this->insertConfig(
1, // order
false, // customizable
"colorfttitle", // category
"colorfttitledark", // id
"Couleur des titres sur fond fonçé", // title
@ -250,6 +254,7 @@ class AppInitCommand extends Command
$this->insertConfig(
2, // order
false, // customizable
"colorfttitle", // category
"colorfttitlelight", // id
"Couleur des titres sur fond claire", // title
@ -265,6 +270,7 @@ class AppInitCommand extends Command
// colorftbody = Couleur des fontes titre
$this->insertConfig(
1, // order
false, // customizable
"colorftbody", // category
"colorftbodydark", // id
"Couleur de la police sur fond fonçé", // title
@ -279,6 +285,7 @@ class AppInitCommand extends Command
$this->insertConfig(
2, // order
false, // customizable
"colorftbody", // category
"colorftbodylight", // id
"Couleur de la police sur fond claire", // title
@ -294,6 +301,7 @@ class AppInitCommand extends Command
// font = nom des polices
$this->insertConfig(
1, // order
false, // customizable
"font", // category
"fonttitle", // id
"Police pour les titres", // title
@ -308,6 +316,7 @@ class AppInitCommand extends Command
$this->insertConfig(
2, // order
false, // customizable
"font", // category
"fontbody", // id
"Police principale", // title
@ -323,10 +332,11 @@ class AppInitCommand extends Command
// logo =
$this->insertConfig(
1, // order
false, // customizable
"logo", // category
"logodark", // id
"Logo sur fond fonçé", // title
"", // value
"logo.png", // value
"logo", // type,
true, // visible
true, // changeable
@ -337,10 +347,11 @@ class AppInitCommand extends Command
$this->insertConfig(
2, // order
false, // customizable
"logo", // category
"logolight", // id
"Logo sur fond clair", // title
"", // value
"logo.png", // value
"logo", // type,
true, // visible
true, // changeable
@ -352,10 +363,11 @@ class AppInitCommand extends Command
// image =
$this->insertConfig(
1, // order
true, // customizable
"image", // category
"imgcontact", // id
"Image Contact", // title
"", // value
"contact.jpg", // value
"image", // type,
true, // visible
true, // changeable
@ -366,10 +378,11 @@ class AppInitCommand extends Command
$this->insertConfig(
1, // order
true, // customizable
"image", // category
"imglink", // id
"Image Liens", // title
"", // value
"link.jpg", // value
"image", // type,
true, // visible
true, // changeable
@ -381,10 +394,11 @@ class AppInitCommand extends Command
// hero =
$this->insertConfig(
1, // order
true, // customizable
"hero", // category
"hero01", // id
"Carrousel 01", // title
"", // value
"hero.jpg", // value
"hero", // type,
true, // visible
true, // changeable
@ -395,6 +409,7 @@ class AppInitCommand extends Command
$this->insertConfig(
2, // order
true, // customizable
"hero", // category
"hero02", // id
"Carrousel 02", // title
@ -409,6 +424,7 @@ class AppInitCommand extends Command
$this->insertConfig(
3, // order
true, // customizable
"hero", // category
"hero03", // id
"Carrousel 03", // title
@ -423,6 +439,7 @@ class AppInitCommand extends Command
$this->insertConfig(
4, // order
true, // customizable
"hero", // category
"hero04", // id
"Carrousel 04", // title
@ -437,6 +454,7 @@ class AppInitCommand extends Command
$this->insertConfig(
5, // order
true, // customizable
"hero", // category
"hero05", // id
"Carrousel 05", // title
@ -452,6 +470,7 @@ class AppInitCommand extends Command
// Social =
$this->insertConfig(
1, // order
false, // customizable
"social", // category
"email", // id
"Email", // title
@ -466,6 +485,7 @@ class AppInitCommand extends Command
$this->insertConfig(
2, // order
true, // customizable
"social", // category
"facebook", // id
"Facebook", // title
@ -480,6 +500,7 @@ class AppInitCommand extends Command
$this->insertConfig(
3, // order
true, // customizable
"social", // category
"instagram", // id
"Instagram", // title
@ -494,6 +515,7 @@ class AppInitCommand extends Command
$this->insertConfig(
4, // order
true, // customizable
"social", // category
"twitter", // id
"Twitter", // title
@ -508,6 +530,7 @@ class AppInitCommand extends Command
$this->insertConfig(
5, // order
true, // customizable
"social", // category
"google", // id
"Google", // title
@ -522,6 +545,7 @@ class AppInitCommand extends Command
$this->insertConfig(
6, // order
true, // customizable
"social", // category
"youtube", // id
"Youtube", // title
@ -534,6 +558,11 @@ class AppInitCommand extends Command
"Le Youtube du site"
);
// Création du compte admin si non existant
$this->insertUser("admin",$this->container->getParameter('appInitpwdadmin'),$this->appname,"Admin",$this->appmailnoreply,['ROLE_ADMIN'],"admin.jpg");
$output->writeln('');
return Command::SUCCESS;
@ -547,6 +576,7 @@ class AppInitCommand extends Command
$entity->setPassword($password);
$entity->setFirstname($firstname);
$entity->setLastname($lastname);
$entity->SetPseudo($username);
$entity->setEmail($email);
$entity->setRoles($roles);
$entity->setAvatar($avatar);
@ -557,41 +587,38 @@ class AppInitCommand extends Command
$this->em->flush();
}
protected function insertCategory($id,$order,$name) {
$metadata = $this->em->getClassMetaData('App:Category');
$metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE);
$metadata->setIdGenerator(new AssignedGenerator());
// Création du compte admin par défaut
$entity = $this->em->getRepository('App:Category')->find($id);
if(!$entity) {
$entity = new Category;
$entity->setId($id);
$entity->setOrder($order);
$entity->setName($name);
$entity->setUsecategoryconfig(false);
$entity->setAppthumbfilter(false);
$entity->setAppthumbheight(0);
$entity->setAppthumbwidth(0);
$entity->setAppthumbfilter(false);
$entity->setAppthumbfiltergrayscale(100);
$entity->setAppthumbfilteropacity(100);
$entity->setAppthumbfiltersepia(0);
$this->em->persist($entity);
}
protected function insertCategory($name) {
// On flush
$this->em->flush();
$users=$this->em->getRepository('App:User')->findAll();
foreach($users as $user) {
$category=$entity = $this->em->getRepository('App:Category')->findOneBy(["user"=>$user]);
if(!$category) {
$category = new Category;
$category->setOrder(1);
$category->setName($name);
$category->setUsecategoryconfig(false);
$category->setAppthumbfilter(false);
$category->setAppthumbheight(0);
$category->setAppthumbwidth(0);
$category->setAppthumbfilter(false);
$category->setAppthumbfiltergrayscale(100);
$category->setAppthumbfilteropacity(100);
$category->setAppthumbfiltersepia(0);
$category->setUser($user);
$this->em->persist($category);
$this->em->flush();
}
}
}
private function insertConfig($order,$category,$id,$title,$value,$type,$visible,$changeable,$required,$grouped,$help) {
$entity=$this->em->getRepository("App:Config")->find($id);
private function insertConfig($order,$customizable,$category,$key,$title,$value,$type,$visible,$changeable,$required,$grouped,$help) {
$entity=$this->em->getRepository("App:Config")->findOneBy(["keyid"=>$key,"user"=>null]);
if(!$entity) {
$entity= new Config();
$entity->setId($id);
$entity->setValue($value);
$entity->setKeyid($key);
$entity->setUser(null);
}
$entity->setDefvalue($value);
$entity->setCategory($category);
$entity->setOrder($order);
$entity->setTitle($title);
@ -601,48 +628,12 @@ class AppInitCommand extends Command
$entity->setRequired($required);
$entity->setGrouped($grouped);
$entity->setHelp($help);
$entity->setCustomizable($customizable&&$changeable&&$visible);
$this->em->persist($entity);
$this->em->flush();
}
private function initMedia() {
// Initialiser Filesystem
$filesystem = new Filesystem();
$sourcePath = $this->container->getParameter('kernel.project_dir') . '/public/styles/medias';
$destinationPath = $this->container->getParameter('kernel.project_dir') . '/public/uploads';
echo "====================";
echo get_current_user();
// Vérifier si le répertoire existe
if (!$filesystem->exists($destinationPath."/logo")) {
$filesystem->mkdir($destinationPath,0777);
$filesystem->mkdir($destinationPath."/image",0777);
$filesystem->mkdir($destinationPath."/logo",0777);
$filesystem->mkdir($destinationPath."/avatar",0777);
$filesystem->mkdir($destinationPath."/hero",0777);
$filesystem->chown($destinationPath, 'apache');
$filesystem->chown($destinationPath."/image",'apache');
$filesystem->chown($destinationPath."/logo",'apache');
$filesystem->chown($destinationPath."/avatar",'apache');
$filesystem->chown($destinationPath."/hero",'apache');
}
/*
$filesystem->copy($sourcePath."/admin.jpg", $destinationPath."/avatar/");
$filesystem->copy($sourcePath."/noavatar.png", $destinationPath."/avatar/");
$filesystem->copy($sourcePath."/system.jpg", $destinationPath."/avatar/");
$filesystem->copy($sourcePath."/contact.jpg", $destinationPath."/image");
$filesystem->copy($sourcePath."/link.jpg", $destinationPath."/image");
$filesystem->copy($sourcePath."/hero.jpg", $destinationPath."/hero");
$filesystem->copy($sourcePath."/logo.png", $destinationPath."/logo");
*/
echo "====================";
}
private function writelnred($string) {
$this->output->writeln('<fg=red>'.$string.'</>');
$this->filesystem->appendToFile($this->rootlog.'cron.log', $string."\n");