Merge branch 'master' into dist/envole/6/master
This commit is contained in:
commit
f54efc703c
@ -102,9 +102,6 @@ class OnlyCommand extends Command
|
||||
$this->only_url = $this->container->getParameter("widonlyoffice_url")."/api/2.0/";
|
||||
$this->only_host = str_replace("https://","",str_replace("http://","",$this->container->getParameter("widonlyoffice_url")));
|
||||
|
||||
//$this->only_url = "https://transnum.oo.ac-dijon.fr"."/api/2.0/";
|
||||
//$this->only_host = "transnum.oo.ac-dijon.fr";
|
||||
|
||||
$this->only_user = $this->container->getParameter("widonlyoffice_user");
|
||||
$this->only_password = $this->container->getParameter("widonlyoffice_password");
|
||||
|
||||
@ -135,6 +132,7 @@ class OnlyCommand extends Command
|
||||
$this->writeln('== AUTHENTIFICATION =================================');
|
||||
\Unirest\Request::verifyPeer(false);
|
||||
\Unirest\Request::verifyHost(false);
|
||||
\Unirest\Request::timeout(5);
|
||||
$headers = ['Host' => $this->only_host, 'Accept' => 'application/json','Content-Type'=>'application/json','Retry-After'=>'5'];
|
||||
$query = array('userName' => $this->only_user, 'password' => $this->only_password);
|
||||
$body = \Unirest\Request\Body::json($query);
|
||||
@ -145,12 +143,11 @@ class OnlyCommand extends Command
|
||||
$headers["Authorization"]=$token;
|
||||
|
||||
// Synchronisation des utilisateur Only sur l'annuaire
|
||||
/*
|
||||
$this->writeln('');
|
||||
$this->writeln('== SYNCHRONISATION ONLY==============================');
|
||||
$response = \Unirest\Request::get($this->only_url.'/settings/ldap/sync',$headers);
|
||||
if($this->koresponse($response)) return 0;
|
||||
*/
|
||||
|
||||
|
||||
// Fichier d'import des utilisateurs only inexistant dans ninegate
|
||||
$this->filesystem->remove($this->rootlog.'toimportfromonly.csv');
|
||||
@ -160,36 +157,36 @@ class OnlyCommand extends Command
|
||||
// Controler les utilisateur only
|
||||
$this->writeln('');
|
||||
$this->writeln('== CONTROLE USER ONLY================================');
|
||||
$kousers=[];
|
||||
$onlyusers=[];
|
||||
$start=0;
|
||||
$response = \Unirest\Request::get($this->only_url.'/people',$headers);
|
||||
if($this->koresponse($response)) return 0;
|
||||
$peoples=$response->body->response;
|
||||
while(isset($response->body->nextIndex)) {
|
||||
$response = \Unirest\Request::get($this->only_url.'/people?startIndex='.$response->body->nextIndex,$headers);
|
||||
if($this->koresponse($response)) return 0;
|
||||
$peoples=array_merge($peoples,$response->body->response);
|
||||
}
|
||||
|
||||
foreach($response->body->response as $onlyuser) {
|
||||
foreach($peoples as $onlyuser) {
|
||||
$user=$this->em->getRepository("CadolesCoreBundle:User")->findBy(["username"=>$onlyuser->userName]);
|
||||
if(!$user) {
|
||||
$this->writelnred("ERREUR ".$onlyuser->userName." existe dans OnlyOffice mais pas dans Ninegate");
|
||||
if($onlyuser->lastName!="") {
|
||||
$string=$onlyuser->userName.";".$onlyuser->firstName.";".$onlyuser->lastName.";".$onlyuser->email.";Autres;ROLE_USER";
|
||||
//$this->filesystem->appendToFile($this->rootlog.'toimportfromonly.csv', $string."\n");
|
||||
}
|
||||
|
||||
$string=$onlyuser->userName.";".$onlyuser->firstName.";".$onlyuser->lastName.";".$onlyuser->email.";Autres;ROLE_USER";
|
||||
$this->filesystem->appendToFile($this->rootlog.'toimportfromonly.csv', $string."\n");
|
||||
}
|
||||
else {
|
||||
// Sauvegarde l'id du useronlyoffice
|
||||
$onlyusers[$onlyuser->id]=$onlyuser->userName;
|
||||
}
|
||||
|
||||
$string=$onlyuser->userName.";".$onlyuser->firstName.";".$onlyuser->lastName.";".$onlyuser->email.";Autres;ROLE_USER";
|
||||
$this->filesystem->appendToFile($this->rootlog.'toimportfromonly.csv', $string."\n");
|
||||
}
|
||||
}
|
||||
|
||||
$response = \Unirest\Request::get($this->only_url.'/people',$headers);
|
||||
if($this->koresponse($response)) return 0;
|
||||
dump($response);
|
||||
|
||||
|
||||
// Controler les utilisateurs ninegate
|
||||
/*
|
||||
$this->writeln('');
|
||||
$this->writeln('== CONTROLE USER NINEGATE============================');
|
||||
/*
|
||||
$users=$this->em->getRepository("CadolesCoreBundle:User")->findAll();
|
||||
foreach($users as $user) {
|
||||
$response = \Unirest\Request::get($this->only_url.'/people/'.$user->getUsername(),$headers);
|
||||
@ -211,7 +208,17 @@ class OnlyCommand extends Command
|
||||
$this->writeln('== INJECTION DES GROUPES ONLY========================');
|
||||
$response = \Unirest\Request::get($this->only_url.'/project?status=0,',$headers);
|
||||
if($this->koresponse($response)) return 0;
|
||||
foreach($response->body->response as $onlygroup) {
|
||||
$projects=$response->body->response;
|
||||
while(isset($response->body->nextIndex)) {
|
||||
$response = \Unirest\Request::get($this->only_url.'/project?status=0&startIndex='.$response->body->nextIndex,$headers);
|
||||
if($this->koresponse($response)) return 0;
|
||||
$projects=array_merge($projects,$response->body->response);
|
||||
}
|
||||
|
||||
foreach($projects as $onlygroup) {
|
||||
// On ne scanne que les groupe ouvert
|
||||
if($onlygroup->status!=0)
|
||||
continue;
|
||||
|
||||
// Le groupe existe-t-il dans ninegate
|
||||
$group=$this->em->getRepository("CadolesCoreBundle:Group")->findBy(["idonlyoffice"=>$onlygroup->id]);
|
||||
@ -223,12 +230,35 @@ class OnlyCommand extends Command
|
||||
if($group)
|
||||
$this->writelnred("ERREUR Groupe déjà existant = ".$namegroup);
|
||||
else{
|
||||
// Le propriétaire du groupe only existe-t-il dans ninegate
|
||||
if(!array_key_exists($onlygroup->responsible->id,$onlyusers)) {
|
||||
if(!array_key_exists($onlygroup->responsible->id,$kousers)) {
|
||||
// Comme on n'a que les 1000 permiers lors du parcours des users only peut etre que lui fait partie de ceux que l'on n'a pas scanné
|
||||
$respuser = \Unirest\Request::get($this->only_url.'/people/'.$onlygroup->responsible->id,$headers);
|
||||
|
||||
// Là normalement on a forcement une réponse positive
|
||||
if(!$this->koresponse($respuser)) {
|
||||
$onlyuser=$respuser->body->response;
|
||||
$user=$this->em->getRepository("CadolesCoreBundle:User")->findBy(["username"=>$onlyuser->userName]);
|
||||
if(!$user) {
|
||||
$kousers[$onlygroup->responsible->id]=$onlygroup->responsible->displayName;
|
||||
|
||||
$string=$onlyuser->userName.";".$onlyuser->firstName.";".$onlyuser->lastName.";".$onlyuser->email.";Autres;ROLE_USER";
|
||||
$this->filesystem->appendToFile($this->rootlog.'toimportfromonly.csv', $string."\n");
|
||||
}
|
||||
else {
|
||||
// Sauvegarde l'id du useronlyoffice
|
||||
$onlyusers[$onlyuser->id]=$onlyuser->userName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Le propriétaire du groupe only existe-t-il dans ninegate
|
||||
if(!array_key_exists($onlygroup->responsible->id,$onlyusers)) {
|
||||
$this->writelnred("ERREUR Propriétaire du Groupe n'existe pas. Group = ".$namegroup. " - User = ".$onlygroup->responsible->displayName);
|
||||
}
|
||||
else {
|
||||
|
||||
// Création du groupe
|
||||
$user=$this->em->getRepository("CadolesCoreBundle:User")->findOneBy(["username"=>$onlyusers[$onlygroup->responsible->id]]);
|
||||
$this->writeln("Création du groupe Ninegate = ".$namegroup);
|
||||
@ -237,7 +267,7 @@ class OnlyCommand extends Command
|
||||
$group=new Group();
|
||||
$group->setLabel($namegroup);
|
||||
$group->setDescription($onlygroup->description);
|
||||
$group->setFgopen(!$onlygroup->isPrivate);
|
||||
$group->setFgopen(false);
|
||||
$group->setFgcanshare(true);
|
||||
$group->setFgcancreatepage(false);
|
||||
$group->setFgcancreatecalendar(false);
|
||||
@ -245,7 +275,9 @@ class OnlyCommand extends Command
|
||||
$group->setFgall(false);
|
||||
$group->setFgtemplate(false);
|
||||
$group->setOwner($user);
|
||||
$group->setPagetemplate($pagetemplate);
|
||||
$group->setIdonlyoffice($onlygroup->id);
|
||||
$group->setNosynconly(true);
|
||||
|
||||
$this->em->persist($group);
|
||||
$this->em->flush();
|
||||
@ -255,18 +287,26 @@ class OnlyCommand extends Command
|
||||
|
||||
// On controle que le groupe a bien page / calendrier / blog
|
||||
$this->ctrlFgcanshare($group,$user,$pagetemplate);
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Rattachement des membres au groupe
|
||||
$group=$this->em->getRepository("CadolesCoreBundle:Group")->findOneBy(["idonlyoffice"=>$onlygroup->id]);
|
||||
$members = \Unirest\Request::get($this->only_url.'/project/'.$onlygroup->id.'/team',$headers);
|
||||
if($this->koresponse($members)) return 0;
|
||||
|
||||
foreach($members->body->response as $member) {
|
||||
// Si non propriétaire du groupe
|
||||
if($member->userName!=$onlyusers[$onlygroup->responsible->id]) {
|
||||
$user=$this->em->getRepository("CadolesCoreBundle:User")->findOneBy(["username"=>$member->userName]);
|
||||
if(!$user) {
|
||||
$this->writelnred("ERREUR Membre du group inexistant. Group = ".$namegroup." - ".$member->userName);
|
||||
if(!array_key_exists($member->id,$kousers)) {
|
||||
$kousers[$member->id]=$member->displayName;
|
||||
$string=$member->userName.";".$member->firstName.";".$member->lastName.";".$member->email.";Autres;ROLE_USER";
|
||||
$this->filesystem->appendToFile($this->rootlog.'toimportfromonly.csv', $string."\n");
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->writeln("Rattachement utilisateur. Group = ".$namegroup." - User = ".$member->userName);
|
||||
@ -280,11 +320,235 @@ class OnlyCommand extends Command
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!$simulate) {
|
||||
$this->em->persist($group);
|
||||
$this->em->flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Injection des groupes ninegate non existant dans only
|
||||
$this->writeln('');
|
||||
$this->writeln('== INJECTION DES GROUPES NINEGATE====================');
|
||||
$groups=$this->em->getRepository("CadolesCoreBundle:Group")->findBy(["fgcanshare"=>true]);
|
||||
foreach($groups as $group) {
|
||||
// Info du groupe
|
||||
$grouptitle=$group->getLabel();
|
||||
$groupdescription=$group->getDescription();
|
||||
$groupowner=$group->getOwner();
|
||||
$groupisprivate=true;
|
||||
$tocreate=false;
|
||||
|
||||
// Si pas de propriétaire de projet on le rattache à admin
|
||||
if(!$groupowner)
|
||||
$groupowner=$this->em->getRepository("CadolesCoreBundle:User")->findOneBy(["username"=>"admin"]);
|
||||
|
||||
if($groupowner) {
|
||||
// On recherche le propriétaire du groupe dans only
|
||||
$respuser = \Unirest\Request::get($this->only_url.'/people/'.$groupowner->getUsername(),$headers);
|
||||
|
||||
// Là normalement on a forcement une réponse positive
|
||||
if(!$this->koresponse($respuser)) {
|
||||
// Le groupe a un identifiant only, on le recherche via cet ID
|
||||
if($group->getIdonlyoffice()) {
|
||||
// On recherche le groupe dans only
|
||||
$respgroup = \Unirest\Request::get($this->only_url.'/project/'.$group->getIdonlyoffice(),$headers);
|
||||
|
||||
// Si le projet existe
|
||||
if(!$this->koresponse($respgroup)) {
|
||||
// On regarde s'il y a des changement
|
||||
if($respgroup->body->response->responsible->userName!=$groupowner->getUsername()||$respgroup->body->response->status!=0||$respgroup->body->response->title!=$grouptitle||$respgroup->body->response->description!=$groupdescription||$respgroup->body->response->isPrivate!=$groupisprivate) {
|
||||
$this->writeln("Modification du groupe dans Only. Group = ".$group->getLabel());
|
||||
if(!$simulate) {
|
||||
// Liste des membres Only
|
||||
$membersOnly=[];
|
||||
$respmember = \Unirest\Request::get($this->only_url.'/project/'.$group->getIdonlyoffice().'/team',$headers);
|
||||
if($this->koresponse($respmember)) {
|
||||
$this->writelnred("ERREUR SUR RECUPERATION DES MEMBRES du Group = ".$group->getLabel());
|
||||
continue;
|
||||
}
|
||||
foreach($respmember->body->response as $member) {
|
||||
array_push($membersOnly,$member->id);
|
||||
}
|
||||
|
||||
// On modifie le groupe only
|
||||
$query = array(
|
||||
'status' => 0,
|
||||
'title' => $grouptitle,
|
||||
'description' => $groupdescription,
|
||||
'responsibleId' => $respuser->body->response->id,
|
||||
'participants' => $membersOnly,
|
||||
'private' => $groupisprivate,
|
||||
'notify' => true
|
||||
);
|
||||
$body = \Unirest\Request\Body::json($query);
|
||||
$respmodif = \Unirest\Request::put($this->only_url.'/project/'.$respgroup->body->response->id,$headers,$body);
|
||||
if($this->koresponse($respmodif)) {
|
||||
$this->writelnred("ERREUR SUR MODIFICATION du Group = ".$group->getLabel());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Sinon c'est qu'il a été supprimé via only : il faut donc le regénérer
|
||||
else {
|
||||
$tocreate=true;
|
||||
}
|
||||
}
|
||||
|
||||
// Sinon c'est que l'on doit le créer dans Only
|
||||
else {
|
||||
$tocreate=true;
|
||||
}
|
||||
|
||||
// Création
|
||||
if($tocreate) {
|
||||
$this->writeln("Création du groupe dans Only. Group = ".$group->getLabel());
|
||||
if(!$simulate) {
|
||||
$query = array(
|
||||
'title' => $grouptitle,
|
||||
'description' => $groupdescription,
|
||||
'responsibleId' => $respuser->body->response->id,
|
||||
'private' => $groupisprivate,
|
||||
'notify' => true
|
||||
);
|
||||
$body = \Unirest\Request\Body::json($query);
|
||||
$respsubmit = \Unirest\Request::post($this->only_url.'/project/withSecurity',$headers,$body);
|
||||
if($this->koresponse($respsubmit)) {
|
||||
$this->writelnred("ERREUR SUR CREATION du Group = ".$group->getLabel());
|
||||
}
|
||||
else {
|
||||
$group->setIdonlyoffice($respsubmit->body->response->id);
|
||||
$this->em->persist($group);
|
||||
$this->em->flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->writeln('');
|
||||
$this->writeln('== RATTACHER LES UTILISATEURS =======================');
|
||||
$groups=$this->em->getRepository("CadolesCoreBundle:Group")->findBy(["fgcanshare"=>true]);
|
||||
foreach($groups as $group) {
|
||||
// Si pas d'erreur on doit avoir à présent le projet dans only rattaché à un groupe ninegate
|
||||
// On va pouvoir s'occuper des membres du groupes
|
||||
if($group->getIdonlyoffice()) {
|
||||
// Liste des membres Ninegate
|
||||
$membersNingate=[];
|
||||
$usergroups=$this->em->getRepository("CadolesCoreBundle:UserGroup")->findBy(["group"=>$group]);
|
||||
foreach($usergroups as $member) {
|
||||
array_push($membersNingate,$member->getUser()->getUsername());
|
||||
}
|
||||
|
||||
// Si groupe sans propriétaire on ajoute forcement admin à la liste des membres du groupe
|
||||
if(!$group->getOwner()) {
|
||||
array_push($membersNingate,"admin");
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Liste des membres Only
|
||||
$membersOnly=[];
|
||||
$respmember = \Unirest\Request::get($this->only_url.'/project/'.$group->getIdonlyoffice().'/team',$headers);
|
||||
if($this->koresponse($respmember)) {
|
||||
$this->writelnred("ERREUR SUR RECUPERATION DES MEMBRES du Group = ".$group->getLabel());
|
||||
continue;
|
||||
}
|
||||
foreach($respmember->body->response as $member) {
|
||||
array_push($membersOnly,$member->userName);
|
||||
}
|
||||
|
||||
|
||||
// On vérifie que chq membre Ninegate sont dans les membres Only et si pas le cas on le rattache
|
||||
foreach($membersNingate as $member) {
|
||||
if(!in_array($member,$membersOnly)) {
|
||||
$this->writeln("Rattachement au groupe ".$group->getLabel()." l'utilisateur ".$member);
|
||||
if(!$simulate) {
|
||||
$respuser = \Unirest\Request::get($this->only_url.'/people/'.$member,$headers);
|
||||
if($this->koresponse($respuser)) {
|
||||
$this->writelnred("ERREUR Utilisateur inexistant dans only = ".$member);
|
||||
}
|
||||
else {
|
||||
$query = array('userId' => $respuser->body->response->id);
|
||||
$body = \Unirest\Request\Body::json($query);
|
||||
$respsubmit = \Unirest\Request::post($this->only_url.'/project/'.$group->getIdonlyoffice().'/team',$headers,$body);
|
||||
if($this->koresponse($respsubmit)) {
|
||||
$this->writelnred("ERREUR SUR RATACHEMENT");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// On vérifie que chq membre Ninegate sont dans les membres Only et si pas le cas on le rattache
|
||||
foreach($membersOnly as $member) {
|
||||
if(!in_array($member,$membersNingate)) {
|
||||
$this->writeln("Detachement au groupe ".$group->getLabel()." l'utilisateur ".$member);
|
||||
if(!$simulate) {
|
||||
$respuser = \Unirest\Request::get($this->only_url.'/people/'.$member,$headers);
|
||||
if($this->koresponse($respuser)) {
|
||||
$this->writelnred("ERREUR Utilisateur inexistant dans only = ".$member);
|
||||
}
|
||||
else {
|
||||
$query = array('userId' => $respuser->body->response->id);
|
||||
$body = \Unirest\Request\Body::json($query);
|
||||
$respsubmit = \Unirest\Request::delete($this->only_url.'/project/'.$group->getIdonlyoffice().'/team',$headers,$body);
|
||||
if($this->koresponse($respsubmit)) {
|
||||
$this->writelnred("ERREUR SUR DETACHEMENT");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->writeln('');
|
||||
$this->writeln('== FERMER LES GROUPES FONCTIONNELS====================');
|
||||
$groups=$this->em->getRepository("CadolesCoreBundle:Group")->findBy(["fgcanshare"=>false]);
|
||||
foreach($groups as $group) {
|
||||
if($group->getIdonlyoffice()) {
|
||||
$grouptitle=$group->getLabel();
|
||||
$groupdescription=$group->getDescription();
|
||||
$groupowner=$group->getOwner();
|
||||
|
||||
// Si pas de propriétaire de projet on le rattache à admin
|
||||
if(!$groupowner)
|
||||
$groupowner=$this->em->getRepository("CadolesCoreBundle:User")->findOneBy(["username"=>"admin"]);
|
||||
|
||||
if($groupowner) {
|
||||
// On recherche le propriétaire du groupe dans only
|
||||
$respuser = \Unirest\Request::get($this->only_url.'/people/'.$groupowner->getUsername(),$headers);
|
||||
if(!$this->koresponse($respuser)) {
|
||||
$respgroup = \Unirest\Request::get($this->only_url.'/project/'.$group->getIdonlyoffice(),$headers);
|
||||
if(!$this->koresponse($respgroup)) {
|
||||
if($respgroup->body->response->status!=1) {
|
||||
$this->writeln("Fermer le groupe dans Only. Group = ".$group->getLabel());
|
||||
if(!$simulate) {
|
||||
// On ferme le projet
|
||||
$query = array(
|
||||
'title' => $grouptitle,
|
||||
'description' => $groupdescription,
|
||||
'responsibleId' => $respuser->body->response->id,
|
||||
'participants' => $respgroup->body->response->participants,
|
||||
'private' => $groupisprivate,
|
||||
'status' => 1,
|
||||
'notify' => true
|
||||
);
|
||||
$body = \Unirest\Request\Body::json($query);
|
||||
$respupdate = \Unirest\Request::put($this->only_url.'/project/'.$group->getIdonlyoffice(),$headers,$body);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->writeln('');
|
||||
|
@ -8,7 +8,7 @@ INSERT IGNORE INTO `niveau01` (`id`, `label`, `siren`) VALUES
|
||||
(-100, 'Interne', 'SIREN');
|
||||
|
||||
INSERT IGNORE INTO `user` (`id`, `niveau01_id`, `username`, `firstname`, `lastname`, `password`, `email`, `avatar`, `role`,`siren`,`authlevel`) VALUES
|
||||
(-100, -100, 'admin', 'Administrateur', 'draaf', '{SSHA}7edyZMIwG4aTOpc6rVXCWrDljOW5K9xW
|
||||
(-100, -100, 'admin', 'Administrateur', 'draaf', '{SSHA}aTs3IqgN93ehIEqy93uWTTyxg5wNa+80
|
||||
', 'admin@ldapbundle.ac-arno.fr', 'admin.jpg', 'ROLE_ADMIN', '130007107', 'simple');
|
||||
|
||||
|
||||
|
@ -933,7 +933,7 @@ class GroupController extends Controller
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
if($group->getOwner()) {
|
||||
$usergroup=$em->getRepository("CadolesCoreBundle:Usergroup")->findOneBy(["user"=>$group->getOwner()]);
|
||||
if($usergroup) {
|
||||
if(!$usergroup) {
|
||||
$key = Uuid::uuid4();
|
||||
$usergroup=new Usergroup;
|
||||
$usergroup->setUser($group->getOwner());
|
||||
|
@ -803,7 +803,14 @@ class UserController extends Controller
|
||||
$error.="<p>Utilisateur = ".$user["login"]." existe déjà</p>";
|
||||
}
|
||||
|
||||
if(strlen($user["login"])<5) $error.="<p>Utilisateur = ".$user["login"]." login trop court doit être >= 5</p>";
|
||||
// On s'assure que le login n'est pas trop court
|
||||
if(strlen($user["login"])<5)
|
||||
$error.="<p>Utilisateur = ".$user["login"]." login trop court doit être >= 5</p>";
|
||||
|
||||
// On s'assure que le username ne contient pas des caractères speciaux
|
||||
$string = preg_replace('~[^@a-zA-Z0-9._-]~', '', $user["login"]);
|
||||
if($string!=$user["login"])
|
||||
$error.="<p>Utilisateur = ".$user["login"]." login avec caractères invalide</p>";
|
||||
|
||||
// On regarde si le email n'est pas déjà existant
|
||||
$userbdd=$em->getRepository('CadolesCoreBundle:User')->findOneBy(["email"=>$user["email"]]);
|
||||
|
@ -156,9 +156,8 @@ class Group
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity="Cadoles\PortalBundle\Entity\Blog", mappedBy="groups")
|
||||
*/
|
||||
protected $blogs;
|
||||
|
||||
|
||||
protected $blogs;
|
||||
|
||||
/**
|
||||
* @var ArrayCollection $message
|
||||
* @var Message
|
||||
@ -167,6 +166,21 @@ class Group
|
||||
*/
|
||||
protected $messages;
|
||||
|
||||
|
||||
// Champs temporaire
|
||||
protected $nosynconly;
|
||||
public function getNosynconly()
|
||||
{
|
||||
return $this->nosynconly;
|
||||
}
|
||||
public function setNosynconly($nosynconly)
|
||||
{
|
||||
$this->nosynconly = $nosynconly;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ATTENTION NE SURTOUT PAS REGEN TOTALEMENT LES SETTER
|
||||
// Methode custom sur les Addxxx et Removexxx
|
||||
|
||||
|
@ -39,7 +39,10 @@ class syncGroup implements EventSubscriber
|
||||
if(!($entity instanceof Group)) return;
|
||||
|
||||
// Synchronisation uniquement si changement de valeur
|
||||
$this->shouldSync = $args->hasChangedField('label');
|
||||
$this->shouldSync = $args->hasChangedField('label') ||
|
||||
$args->hasChangedField('description') ||
|
||||
$args->hasChangedField('owner') ||
|
||||
$args->hasChangedField('fgcanshare');
|
||||
|
||||
if($args->hasChangedField('label')) $this->oldid=$args->getOldValue('label');
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ use Cadoles\CoreBundle\Entity\User;
|
||||
use Cadoles\CoreBundle\Entity\Group;
|
||||
use Cadoles\CoreBundle\Entity\UserGroup;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class onlyService
|
||||
{
|
||||
@ -17,7 +18,8 @@ class onlyService
|
||||
protected $only_host;
|
||||
protected $only_user;
|
||||
protected $only_password;
|
||||
protected $debug = true;
|
||||
protected $debug = false;
|
||||
protected $headers = [];
|
||||
|
||||
public function __construct($container, EntityManager $em)
|
||||
{
|
||||
@ -45,8 +47,45 @@ class onlyService
|
||||
//==================================================================================================================================================================
|
||||
|
||||
public function syncUser(User $user) {
|
||||
error_log("==SYNC ONLY USER==========================================================");
|
||||
// Recherche utilisateur eportail
|
||||
$this->mydebug("==SYNC ONLY USER==========================================================");
|
||||
|
||||
// Authentification à Only
|
||||
if($this->authOnly()) {
|
||||
// Recherche utilisateur only
|
||||
$this->mydebug("Recherche utilisateur only");
|
||||
$respuser = \Unirest\Request::get($this->only_url.'/people/'.$user->getUsername(),$this->headers);
|
||||
|
||||
// Si existe modification
|
||||
if(!$this->koresponse($respuser)) {
|
||||
$this->mydebug("Modification user = ".$user->getUsername());
|
||||
$onlyuser=$respuser->body->response;
|
||||
|
||||
// Si véritable modification
|
||||
if($onlyuser->firstName!=$user->getFirstname()||$onlyuser->lastName!=$user->getLastname()||$onlyuser->email!=$user->getEmail()) {
|
||||
$this->mydebug("Lancer la modification");
|
||||
$this->mydebug($onlyuser->firstName." !=".$user->getFirstname());
|
||||
$this->mydebug($onlyuser->lastName." !=".$user->getLastname());
|
||||
$this->mydebug($onlyuser->email." !=".$user->getEmail());
|
||||
|
||||
$query = array(
|
||||
'firstName' => $user->getFirstname(),
|
||||
'lastName' => $user->getLastname(),
|
||||
'email' => $user->getEmail(),
|
||||
);
|
||||
$body = \Unirest\Request\Body::json($query);
|
||||
$respupdate = \Unirest\Request::put($this->only_url.'/people/'.$onlyuser->id,$this->headers,$body);
|
||||
}
|
||||
}
|
||||
|
||||
// Sinon création
|
||||
else {
|
||||
$this->mydebug("Création user = ".$user->getUsername());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//$respuser = \Unirest\Request::get($this->only_url.'/people/'.$onlygroup->responsible->id,$this->headers);
|
||||
|
||||
// Correspondance profil ldapuser = profil eportail
|
||||
|
||||
@ -71,59 +110,245 @@ class onlyService
|
||||
//== Function Groupe================================================================================================================================================
|
||||
//==================================================================================================================================================================
|
||||
|
||||
public function syncGroup(Group $group, $oldid) {
|
||||
error_log("==SYNC ONLY GROUP=========================================================");
|
||||
public function syncGroup(Group $group, $oldid) {
|
||||
if($group->getNosynconly()) return true;
|
||||
|
||||
// Renommage du précédent groupe
|
||||
if(isset($oldid)&&$oldid!=$group->getLabel()) {
|
||||
$this->mydebug("==SYNC ONLY GROUP=========================================================");
|
||||
|
||||
// Authentification à Only
|
||||
if($this->authOnly()) {
|
||||
// Si groupe de travail
|
||||
if($group->getFgcanshare()) {
|
||||
// Info du groupe
|
||||
$grouptitle=$group->getLabel();
|
||||
$groupdescription=$group->getDescription();
|
||||
$groupowner=$group->getOwner();
|
||||
$groupisprivate=true;
|
||||
$tocreate=false;
|
||||
|
||||
// Si pas de propriétaire de projet on le rattache à admin
|
||||
if(!$groupowner)
|
||||
$groupowner=$this->em->getRepository("CadolesCoreBundle:USer")->findOneBy(["username"=>"admin"]);
|
||||
|
||||
if($groupowner) {
|
||||
// On recherche le propriétaire du groupe dans only
|
||||
$this->mydebug("Recherche du propriétaire du group only");
|
||||
$respuser = \Unirest\Request::get($this->only_url.'/people/'.$groupowner->getUsername(),$this->headers);
|
||||
|
||||
// Normalement on a toujours le propriétaire dans only
|
||||
if(!$this->koresponse($respuser)) {
|
||||
// Si idonlyoffice de lié
|
||||
if($group->getIdonlyoffice()) {
|
||||
// Recherche groupe only
|
||||
$this->mydebug("Recherche group only ".$group->getIdonlyoffice());
|
||||
$respgroup = \Unirest\Request::get($this->only_url.'/project/'.$group->getIdonlyoffice(),$this->headers);
|
||||
|
||||
// Si existe modification
|
||||
if(!$this->koresponse($respgroup)) {
|
||||
$this->mydebug("Modification Group = ".$group->getLabel());
|
||||
$onlygroup=$respgroup->body->response;
|
||||
|
||||
// Si véritable modification
|
||||
if($onlygroup->status!=0||$onlygroup->responsible->userName!=$groupowner->getUsername()||$onlygroup->title!=$grouptitle||$onlygroup->description!=$groupdescription||$onlygroup->isPrivate!=$groupisprivate) {
|
||||
$this->mydebug("Lancer la modification");
|
||||
$this->mydebug($respuser->body->response->userName." != ".$groupowner->getUsername());
|
||||
$this->mydebug($onlygroup->title." != ".$grouptitle);
|
||||
$this->mydebug($onlygroup->description." != ".$groupdescription);
|
||||
$this->mydebug($onlygroup->isPrivate." != ".$groupisprivate);
|
||||
$this->mydebug($onlygroup->status." != 0");
|
||||
|
||||
// Liste des membres Only
|
||||
$membersOnly=[];
|
||||
$respmember = \Unirest\Request::get($this->only_url.'/project/'.$group->getIdonlyoffice().'/team',$this->headers);
|
||||
if(!$this->koresponse($respmember)) {
|
||||
foreach($respmember->body->response as $member) {
|
||||
array_push($membersOnly,$member->id);
|
||||
}
|
||||
|
||||
$query = array(
|
||||
'title' => $grouptitle,
|
||||
'description' => $groupdescription,
|
||||
'responsibleId' => $respuser->body->response->id,
|
||||
'participants' => $membersOnly,
|
||||
'private' => $groupisprivate,
|
||||
'status' => 0,
|
||||
'notify' => true
|
||||
);
|
||||
$body = \Unirest\Request\Body::json($query);
|
||||
$respupdate = \Unirest\Request::put($this->only_url.'/project/'.$onlygroup->id,$this->headers,$body);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sinon c'est qu'il a été supprimé via only : il faut donc le regénérer
|
||||
else {
|
||||
$tocreate=true;
|
||||
}
|
||||
}
|
||||
|
||||
// Sinon il faut le créer dans only
|
||||
else {
|
||||
$tocreate=true;
|
||||
}
|
||||
|
||||
// Création
|
||||
if($tocreate) {
|
||||
$this->mydebug("Création Group = ".$group->getLabel());
|
||||
$query = array(
|
||||
'title' => $grouptitle,
|
||||
'description' => $groupdescription,
|
||||
'responsibleId' => $respuser->body->response->id,
|
||||
'private' => $groupisprivate,
|
||||
'notify' => true
|
||||
);
|
||||
$body = \Unirest\Request\Body::json($query);
|
||||
$respsubmit = \Unirest\Request::post($this->only_url.'/project/withSecurity',$this->headers,$body);
|
||||
if(!$this->koresponse($respsubmit)) {
|
||||
$group->setIdonlyoffice($respsubmit->body->response->id);
|
||||
$this->em->persist($group);
|
||||
$this->em->flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Si non groupe de travail mais avec un id Only, on supprime le groupe only
|
||||
elseif($group->getIdonlyoffice()) {
|
||||
$this->mydebug("Groupe lié à only mais qui n'est plus un groupe de travail");
|
||||
$this->delGroup($group);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// On recherche le groupe à insérer / modifier
|
||||
public function delGroup(Group $group) {
|
||||
// Si groupe associé à un groupe only
|
||||
if($group->getIdonlyoffice()) {
|
||||
$grouptitle=$group->getLabel();
|
||||
$groupdescription=$group->getDescription();
|
||||
$groupowner=$group->getOwner();
|
||||
$groupisprivate=true;
|
||||
|
||||
// Si existe modification = rien à faire normalement
|
||||
// Sinon création
|
||||
// Si pas de propriétaire de projet on le rattache à admin
|
||||
if(!$groupowner)
|
||||
$groupowner=$this->em->getRepository("CadolesCoreBundle:User")->findOneBy(["username"=>"admin"]);
|
||||
|
||||
return true;
|
||||
}
|
||||
if($groupowner&&$this->authOnly()) {
|
||||
// On recherche le propriétaire du groupe dans only
|
||||
$respuser = \Unirest\Request::get($this->only_url.'/people/'.$groupowner->getUsername(),$this->headers);
|
||||
if(!$this->koresponse($respuser)) {
|
||||
$respgroup = \Unirest\Request::get($this->only_url.'/project/'.$group->getIdonlyoffice(),$this->headers);
|
||||
if(!$this->koresponse($respgroup)) {
|
||||
$this->mydebug("Fermer le groupe ".$group->getLabel()." ".$group->getIdonlyoffice());
|
||||
|
||||
public function delGroup(Group $group) {
|
||||
$membersOnly=[];
|
||||
$respmember = \Unirest\Request::get($this->only_url.'/project/'.$group->getIdonlyoffice().'/team',$this->headers);
|
||||
if(!$this->koresponse($respmember)) {
|
||||
foreach($respmember->body->response as $member) {
|
||||
array_push($membersOnly,$member->id);
|
||||
}
|
||||
|
||||
// On recherche le groupe eportail
|
||||
// On ferme le projet
|
||||
$query = array(
|
||||
'title' => $grouptitle,
|
||||
'description' => $groupdescription,
|
||||
'responsibleId' => $respuser->body->response->id,
|
||||
'participants' => $membersOnly,
|
||||
'private' => $groupisprivate,
|
||||
'status' => 1,
|
||||
'notify' => true
|
||||
);
|
||||
$body = \Unirest\Request\Body::json($query);
|
||||
$respupdate = \Unirest\Request::put($this->only_url.'/project/'.$group->getIdonlyoffice(),$this->headers,$body);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Si existe suppression
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//==================================================================================================================================================================
|
||||
//== Function GroupUser=============================================================================================================================================
|
||||
//==================================================================================================================================================================
|
||||
|
||||
public function delUserGroup(UserGroup $usergroup) {
|
||||
|
||||
// Recherche de l'utilisateur eportail
|
||||
|
||||
// s'il existe
|
||||
// Recherche du groupe
|
||||
|
||||
// si le groupe existe
|
||||
// Suppression du rattachement
|
||||
// Si groupe lié à only
|
||||
if($usergroup->getGroup()->getIdonlyoffice()) {
|
||||
if($this->authOnly()) {
|
||||
$respuser = \Unirest\Request::get($this->only_url.'/people/'.$usergroup->getUser()->getUsername(),$this->headers);
|
||||
if(!$this->koresponse($respuser)) {
|
||||
$query = array('userId' => $respuser->body->response->id);
|
||||
$body = \Unirest\Request\Body::json($query);
|
||||
$respsubmit = \Unirest\Request::delete($this->only_url.'/project/'.$usergroup->getGroup()->getIdonlyoffice().'/team',$this->headers,$body);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function addUserGroup(UserGroup $usergroup) {
|
||||
|
||||
// Recherche de l'utilisateur eportail
|
||||
|
||||
// s'il existe
|
||||
// Recherche du groupe
|
||||
|
||||
// si le groupe existe
|
||||
// Création du rattachement
|
||||
// Si groupe lié à only
|
||||
if($usergroup->getGroup()->getIdonlyoffice()) {
|
||||
if($this->authOnly()) {
|
||||
$respuser = \Unirest\Request::get($this->only_url.'/people/'.$usergroup->getUser()->getUsername(),$this->headers);
|
||||
if(!$this->koresponse($respuser)) {
|
||||
$query = array('userId' => $respuser->body->response->id);
|
||||
$body = \Unirest\Request\Body::json($query);
|
||||
$respsubmit = \Unirest\Request::post($this->only_url.'/project/'.$usergroup->getGroup()->getIdonlyoffice().'/team',$this->headers,$body);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private function authOnly() {
|
||||
// Only Office est-il dans le domaine
|
||||
if(stripos($this->only_url,"/")===0)
|
||||
$this->only_url="https://".$this->container->getParameter("weburl").$this->only_url;
|
||||
$indomaine = (stripos($this->only_url,$this->container->getParameter("weburl"))!==false);
|
||||
|
||||
// Si hors domaine on utilise le proxy si proxy il y a
|
||||
if(!$indomaine) {
|
||||
$PROXYactivate = $this->em->getRepository("CadolesCoreBundle:Config")->find("PROXYactivate")->getValue();
|
||||
if($PROXYactivate) {
|
||||
$PROXYserver = $this->em->getRepository("CadolesCoreBundle:Config")->find("PROXYserver")->getValue();
|
||||
$PROXYport = $this->em->getRepository("CadolesCoreBundle:Config")->find("PROXYport")->getValue();
|
||||
\Unirest\Request::proxy($PROXYserver, $PROXYport, CURLPROXY_HTTP, true);
|
||||
}
|
||||
}
|
||||
|
||||
\Unirest\Request::verifyPeer(false);
|
||||
\Unirest\Request::verifyHost(false);
|
||||
\Unirest\Request::timeout(5);
|
||||
$this->headers = ['Host' => $this->only_host, 'Accept' => 'application/json','Content-Type'=>'application/json','Retry-After'=>'5'];
|
||||
$query = array('userName' => $this->only_user, 'password' => $this->only_password);
|
||||
$body = \Unirest\Request\Body::json($query);
|
||||
|
||||
$response = \Unirest\Request::post($this->only_url.'/authentication',$this->headers,$body);
|
||||
if($this->koresponse($response)) return false;
|
||||
$token=$response->body->response->token;
|
||||
$this->headers["Authorization"]=$token;
|
||||
return true;
|
||||
}
|
||||
|
||||
private function koresponse($response) {
|
||||
if($response->code>=Response::HTTP_BAD_REQUEST) {
|
||||
$this->mydebug("ERREUR ".$response->code);
|
||||
if(property_exists($response,"body") && property_exists($response->body,"error")) $this->mydebug("ERREUR ".$response->body->error->message);;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private function mydebug($texte) {
|
||||
if($this->debug) error_log("==SYNC ONLY USER==========================================================");
|
||||
if($this->debug) error_log($texte);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -994,7 +994,7 @@ class InitDataCommand extends ContainerAwareCommand
|
||||
$entityWidget->setParameter($parameter);
|
||||
$em->persist($entityWidget);
|
||||
}
|
||||
else {
|
||||
elseif($entityWidget) {
|
||||
$em->remove($entityWidget);
|
||||
}
|
||||
|
||||
@ -1241,21 +1241,23 @@ class InitDataCommand extends ContainerAwareCommand
|
||||
if(!$entityPagewidget) {
|
||||
$entityWidget = $em->getRepository('CadolesPortalBundle:Widget')->find($widgetid);
|
||||
|
||||
$entityPagewidget = new Pagewidget();
|
||||
$entityPagewidget->setId($id);
|
||||
$entityPagewidget->setLoc($loc);
|
||||
$entityPagewidget->setRoworder($order);
|
||||
$entityPagewidget->setName($title);
|
||||
$entityPagewidget->setHeight($entityWidget->getHeight());
|
||||
$entityPagewidget->setAutoajust($entityWidget->getAutoajust());
|
||||
$entityPagewidget->setBorder($border);
|
||||
$entityPagewidget->setOpened($entityWidget->getOpened());
|
||||
$entityPagewidget->setIcon($entityWidget->getIcon());
|
||||
$entityPagewidget->setPage($entityPage);
|
||||
$entityPagewidget->setWidget($entityWidget);
|
||||
$entityPagewidget->setParameter($fields);
|
||||
$em->persist($entityPagewidget);
|
||||
$em->flush();
|
||||
if($entityWidget) {
|
||||
$entityPagewidget = new Pagewidget();
|
||||
$entityPagewidget->setId($id);
|
||||
$entityPagewidget->setLoc($loc);
|
||||
$entityPagewidget->setRoworder($order);
|
||||
$entityPagewidget->setName($title);
|
||||
$entityPagewidget->setHeight($entityWidget->getHeight());
|
||||
$entityPagewidget->setAutoajust($entityWidget->getAutoajust());
|
||||
$entityPagewidget->setBorder($border);
|
||||
$entityPagewidget->setOpened($entityWidget->getOpened());
|
||||
$entityPagewidget->setIcon($entityWidget->getIcon());
|
||||
$entityPagewidget->setPage($entityPage);
|
||||
$entityPagewidget->setWidget($entityWidget);
|
||||
$entityPagewidget->setParameter($fields);
|
||||
$em->persist($entityPagewidget);
|
||||
$em->flush();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ Alias /ninegate /var/www/html/ninegate/web
|
||||
php_admin_flag allow_url_fopen On
|
||||
</Directory>
|
||||
|
||||
%if %%getVar("ninegate_activate_websocket", 'non') == "oui"
|
||||
Listen %%adresse_ip_eth0:%%ninegate_websocket_portexterne
|
||||
<VirtualHost %%adresse_ip_eth0:%%ninegate_websocket_portexterne>
|
||||
ErrorLog /var/log/apache2/ssl_error.log
|
||||
@ -26,4 +27,5 @@ Listen %%adresse_ip_eth0:%%ninegate_websocket_portexterne
|
||||
|
||||
ProxyPass / ws://%%adresse_ip_eth0:%%ninegate_websocket_portinterne retry=0 keepalive=On
|
||||
ProxyPassReverse / ws://%%adresse_ip_eth0:%%ninegate_websocket_portinterne retry=0
|
||||
</VirtualHost>
|
||||
</VirtualHost>
|
||||
%end if
|
@ -45,9 +45,9 @@ parameters:
|
||||
websocket_portinterne: %%ninegate_websocket_portinterne
|
||||
%else
|
||||
websocket_activate: false
|
||||
websocket_host:
|
||||
websocket_port:
|
||||
websocket_portinterne:
|
||||
websocket_host: %%web_url
|
||||
websocket_port: 80
|
||||
websocket_portinterne: 80
|
||||
%end if
|
||||
%if %%getVar("ninegate_activate_portal", 'non') == "oui"
|
||||
portal_activate: true
|
||||
|
Loading…
Reference in New Issue
Block a user