sync only
This commit is contained in:
parent
8e9ff10223
commit
5e9d7765ce
|
@ -186,6 +186,7 @@ class OnlyCommand extends Command
|
||||||
// Controler les utilisateurs ninegate
|
// Controler les utilisateurs ninegate
|
||||||
$this->writeln('');
|
$this->writeln('');
|
||||||
$this->writeln('== CONTROLE USER NINEGATE============================');
|
$this->writeln('== CONTROLE USER NINEGATE============================');
|
||||||
|
/*
|
||||||
$users=$this->em->getRepository("CadolesCoreBundle:User")->findAll();
|
$users=$this->em->getRepository("CadolesCoreBundle:User")->findAll();
|
||||||
foreach($users as $user) {
|
foreach($users as $user) {
|
||||||
$response = \Unirest\Request::get($this->only_url.'/people/'.$user->getUsername(),$headers);
|
$response = \Unirest\Request::get($this->only_url.'/people/'.$user->getUsername(),$headers);
|
||||||
|
@ -193,6 +194,7 @@ class OnlyCommand extends Command
|
||||||
$this->writelnred("ERREUR ".$user->getUsername()." existe dans Ninegate mais pas dans OnlyOffice");
|
$this->writelnred("ERREUR ".$user->getUsername()." existe dans Ninegate mais pas dans OnlyOffice");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// On recherche la page template de group
|
// On recherche la page template de group
|
||||||
$pagetemplate=$this->em->getRepository("CadolesPortalBundle:Page")->findOneBy(["parentfor"=>"group"]);
|
$pagetemplate=$this->em->getRepository("CadolesPortalBundle:Page")->findOneBy(["parentfor"=>"group"]);
|
||||||
|
@ -208,12 +210,16 @@ class OnlyCommand extends Command
|
||||||
if($this->koresponse($response)) return 0;
|
if($this->koresponse($response)) return 0;
|
||||||
$projects=$response->body->response;
|
$projects=$response->body->response;
|
||||||
while(isset($response->body->nextIndex)) {
|
while(isset($response->body->nextIndex)) {
|
||||||
$response = \Unirest\Request::get($this->only_url.'/people?startIndex='.$response->body->nextIndex,$headers);
|
$response = \Unirest\Request::get($this->only_url.'/project?status=0&startIndex='.$response->body->nextIndex,$headers);
|
||||||
if($this->koresponse($response)) return 0;
|
if($this->koresponse($response)) return 0;
|
||||||
$projects=array_merge($projects,$response->body->response);
|
$projects=array_merge($projects,$response->body->response);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($projects as $onlygroup) {
|
foreach($projects as $onlygroup) {
|
||||||
|
// On ne scanne que les groupe ouvert
|
||||||
|
if($onlygroup->status!=0)
|
||||||
|
continue;
|
||||||
|
|
||||||
// Le groupe existe-t-il dans ninegate
|
// Le groupe existe-t-il dans ninegate
|
||||||
$group=$this->em->getRepository("CadolesCoreBundle:Group")->findBy(["idonlyoffice"=>$onlygroup->id]);
|
$group=$this->em->getRepository("CadolesCoreBundle:Group")->findBy(["idonlyoffice"=>$onlygroup->id]);
|
||||||
if(!$group) {
|
if(!$group) {
|
||||||
|
@ -253,7 +259,6 @@ class OnlyCommand extends Command
|
||||||
$this->writelnred("ERREUR Propriétaire du Groupe n'existe pas. Group = ".$namegroup. " - User = ".$onlygroup->responsible->displayName);
|
$this->writelnred("ERREUR Propriétaire du Groupe n'existe pas. Group = ".$namegroup. " - User = ".$onlygroup->responsible->displayName);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
// Création du groupe
|
// Création du groupe
|
||||||
$user=$this->em->getRepository("CadolesCoreBundle:User")->findOneBy(["username"=>$onlyusers[$onlygroup->responsible->id]]);
|
$user=$this->em->getRepository("CadolesCoreBundle:User")->findOneBy(["username"=>$onlyusers[$onlygroup->responsible->id]]);
|
||||||
$this->writeln("Création du groupe Ninegate = ".$namegroup);
|
$this->writeln("Création du groupe Ninegate = ".$namegroup);
|
||||||
|
@ -272,6 +277,7 @@ class OnlyCommand extends Command
|
||||||
$group->setOwner($user);
|
$group->setOwner($user);
|
||||||
$group->setPagetemplate($pagetemplate);
|
$group->setPagetemplate($pagetemplate);
|
||||||
$group->setIdonlyoffice($onlygroup->id);
|
$group->setIdonlyoffice($onlygroup->id);
|
||||||
|
$group->setNosynconly(true);
|
||||||
|
|
||||||
$this->em->persist($group);
|
$this->em->persist($group);
|
||||||
$this->em->flush();
|
$this->em->flush();
|
||||||
|
@ -281,12 +287,15 @@ class OnlyCommand extends Command
|
||||||
|
|
||||||
// On controle que le groupe a bien page / calendrier / blog
|
// On controle que le groupe a bien page / calendrier / blog
|
||||||
$this->ctrlFgcanshare($group,$user,$pagetemplate);
|
$this->ctrlFgcanshare($group,$user,$pagetemplate);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rattachement des membres au groupe
|
// Rattachement des membres au groupe
|
||||||
$group=$this->em->getRepository("CadolesCoreBundle:Group")->findOneBy(["idonlyoffice"=>$onlygroup->id]);
|
$group=$this->em->getRepository("CadolesCoreBundle:Group")->findOneBy(["idonlyoffice"=>$onlygroup->id]);
|
||||||
$members = \Unirest\Request::get($this->only_url.'/project/'.$onlygroup->id.'/team',$headers);
|
$members = \Unirest\Request::get($this->only_url.'/project/'.$onlygroup->id.'/team',$headers);
|
||||||
if($this->koresponse($members)) return 0;
|
if($this->koresponse($members)) return 0;
|
||||||
|
|
||||||
foreach($members->body->response as $member) {
|
foreach($members->body->response as $member) {
|
||||||
// Si non propriétaire du groupe
|
// Si non propriétaire du groupe
|
||||||
if($member->userName!=$onlyusers[$onlygroup->responsible->id]) {
|
if($member->userName!=$onlyusers[$onlygroup->responsible->id]) {
|
||||||
|
@ -311,10 +320,16 @@ class OnlyCommand extends Command
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!$simulate) {
|
||||||
|
$this->em->persist($group);
|
||||||
|
$this->em->flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Injection des groupes ninegate non existant dans only
|
// Injection des groupes ninegate non existant dans only
|
||||||
$this->writeln('');
|
$this->writeln('');
|
||||||
|
@ -346,13 +361,32 @@ class OnlyCommand extends Command
|
||||||
// Si le projet existe
|
// Si le projet existe
|
||||||
if(!$this->koresponse($respgroup)) {
|
if(!$this->koresponse($respgroup)) {
|
||||||
// On regarde s'il y a des changement
|
// On regarde s'il y a des changement
|
||||||
if($respgroup->body->response->responsible->userName!=$groupowner->getUsername()||$respgroup->body->response->title!=$grouptitle||$respgroup->body->response->description!=$groupdescription||$respgroup->body->response->isPrivate!=$groupisprivate) {
|
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());
|
$this->writeln("Modification du groupe dans Only. Group = ".$group->getLabel());
|
||||||
if(!$simulate) {
|
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
|
// On modifie le groupe only
|
||||||
$query = array('title' => $grouptitle, 'description' => $groupdescription, 'responsibleId' => $respuser->body->response->id, 'private' => $groupisprivate);
|
$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);
|
$body = \Unirest\Request\Body::json($query);
|
||||||
$respmodif = \Unirest\Request::put($this->only_url.'/project/'.$respgroup->body->response->id."/withSecurityInfo",$headers,$body);
|
$respmodif = \Unirest\Request::put($this->only_url.'/project/'.$respgroup->body->response->id,$headers,$body);
|
||||||
if($this->koresponse($respmodif)) {
|
if($this->koresponse($respmodif)) {
|
||||||
$this->writelnred("ERREUR SUR MODIFICATION du Group = ".$group->getLabel());
|
$this->writelnred("ERREUR SUR MODIFICATION du Group = ".$group->getLabel());
|
||||||
}
|
}
|
||||||
|
@ -395,13 +429,19 @@ class OnlyCommand extends Command
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$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
|
// 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
|
// On va pouvoir s'occuper des membres du groupes
|
||||||
if($group->getIdonlyoffice()) {
|
if($group->getIdonlyoffice()) {
|
||||||
// Liste des membres Ninegate
|
// Liste des membres Ninegate
|
||||||
$membersNingate=[];
|
$membersNingate=[];
|
||||||
foreach($group->getUsers() as $member) {
|
$usergroups=$this->em->getRepository("CadolesCoreBundle:UserGroup")->findBy(["group"=>$group]);
|
||||||
|
foreach($usergroups as $member) {
|
||||||
array_push($membersNingate,$member->getUser()->getUsername());
|
array_push($membersNingate,$member->getUser()->getUsername());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -410,6 +450,8 @@ class OnlyCommand extends Command
|
||||||
array_push($membersNingate,"admin");
|
array_push($membersNingate,"admin");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Liste des membres Only
|
// Liste des membres Only
|
||||||
$membersOnly=[];
|
$membersOnly=[];
|
||||||
$respmember = \Unirest\Request::get($this->only_url.'/project/'.$group->getIdonlyoffice().'/team',$headers);
|
$respmember = \Unirest\Request::get($this->only_url.'/project/'.$group->getIdonlyoffice().'/team',$headers);
|
||||||
|
@ -465,6 +507,48 @@ class OnlyCommand extends Command
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$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('');
|
$this->writeln('');
|
||||||
|
|
|
@ -158,7 +158,6 @@ class Group
|
||||||
*/
|
*/
|
||||||
protected $blogs;
|
protected $blogs;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var ArrayCollection $message
|
* @var ArrayCollection $message
|
||||||
* @var Message
|
* @var Message
|
||||||
|
@ -167,6 +166,21 @@ class Group
|
||||||
*/
|
*/
|
||||||
protected $messages;
|
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
|
// ATTENTION NE SURTOUT PAS REGEN TOTALEMENT LES SETTER
|
||||||
// Methode custom sur les Addxxx et Removexxx
|
// Methode custom sur les Addxxx et Removexxx
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ class onlyService
|
||||||
protected $only_host;
|
protected $only_host;
|
||||||
protected $only_user;
|
protected $only_user;
|
||||||
protected $only_password;
|
protected $only_password;
|
||||||
protected $debug = true;
|
protected $debug = false;
|
||||||
protected $headers = [];
|
protected $headers = [];
|
||||||
|
|
||||||
public function __construct($container, EntityManager $em)
|
public function __construct($container, EntityManager $em)
|
||||||
|
@ -111,6 +111,8 @@ class onlyService
|
||||||
//==================================================================================================================================================================
|
//==================================================================================================================================================================
|
||||||
|
|
||||||
public function syncGroup(Group $group, $oldid) {
|
public function syncGroup(Group $group, $oldid) {
|
||||||
|
if($group->getNosynconly()) return true;
|
||||||
|
|
||||||
$this->mydebug("==SYNC ONLY GROUP=========================================================");
|
$this->mydebug("==SYNC ONLY GROUP=========================================================");
|
||||||
|
|
||||||
// Authentification à Only
|
// Authentification à Only
|
||||||
|
@ -147,21 +149,34 @@ class onlyService
|
||||||
$onlygroup=$respgroup->body->response;
|
$onlygroup=$respgroup->body->response;
|
||||||
|
|
||||||
// Si véritable modification
|
// Si véritable modification
|
||||||
if($onlygroup->responsible->userName!=$groupowner->getUsername()||$onlygroup->title!=$grouptitle||$onlygroup->description!=$groupdescription||$onlygroup->isPrivate!=$groupisprivate) {
|
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("Lancer la modification");
|
||||||
$this->mydebug($respuser->body->response->userName." !=".$groupowner->getUsername());
|
$this->mydebug($respuser->body->response->userName." != ".$groupowner->getUsername());
|
||||||
$this->mydebug($onlygroup->title." !=".$grouptitle);
|
$this->mydebug($onlygroup->title." != ".$grouptitle);
|
||||||
$this->mydebug($onlygroup->description." !=".$groupdescription);
|
$this->mydebug($onlygroup->description." != ".$groupdescription);
|
||||||
$this->mydebug($onlygroup->isPrivate." !=".$groupisprivate);
|
$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(
|
$query = array(
|
||||||
'title' => $grouptitle,
|
'title' => $grouptitle,
|
||||||
'description' => $groupdescription,
|
'description' => $groupdescription,
|
||||||
'responsibleId' => $respuser->body->response->id,
|
'responsibleId' => $respuser->body->response->id,
|
||||||
'private' => $groupisprivate
|
'participants' => $membersOnly,
|
||||||
|
'private' => $groupisprivate,
|
||||||
|
'status' => 0,
|
||||||
|
'notify' => true
|
||||||
);
|
);
|
||||||
$body = \Unirest\Request\Body::json($query);
|
$body = \Unirest\Request\Body::json($query);
|
||||||
$respupdate = \Unirest\Request::put($this->only_url.'/project/'.$onlygroup->id."/withSecurityInfo",$this->headers,$body);
|
$respupdate = \Unirest\Request::put($this->only_url.'/project/'.$onlygroup->id,$this->headers,$body);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,17 +213,60 @@ class onlyService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Si non groupe de travail mais avec un id Only
|
// 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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delGroup(Group $group) {
|
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;
|
||||||
|
|
||||||
// On recherche le groupe eportail
|
// Si pas de propriétaire de projet on le rattache à admin
|
||||||
|
if(!$groupowner)
|
||||||
|
$groupowner=$this->em->getRepository("CadolesCoreBundle:User")->findOneBy(["username"=>"admin"]);
|
||||||
|
|
||||||
// Si existe suppression
|
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());
|
||||||
|
|
||||||
|
$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 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -218,25 +276,31 @@ class onlyService
|
||||||
//==================================================================================================================================================================
|
//==================================================================================================================================================================
|
||||||
|
|
||||||
public function delUserGroup(UserGroup $usergroup) {
|
public function delUserGroup(UserGroup $usergroup) {
|
||||||
|
// Si groupe lié à only
|
||||||
// Recherche de l'utilisateur eportail
|
if($usergroup->getGroup()->getIdonlyoffice()) {
|
||||||
|
if($this->authOnly()) {
|
||||||
// s'il existe
|
$respuser = \Unirest\Request::get($this->only_url.'/people/'.$usergroup->getUser()->getUsername(),$this->headers);
|
||||||
// Recherche du groupe
|
if(!$this->koresponse($respuser)) {
|
||||||
|
$query = array('userId' => $respuser->body->response->id);
|
||||||
// si le groupe existe
|
$body = \Unirest\Request\Body::json($query);
|
||||||
// Suppression du rattachement
|
$respsubmit = \Unirest\Request::delete($this->only_url.'/project/'.$usergroup->getGroup()->getIdonlyoffice().'/team',$this->headers,$body);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addUserGroup(UserGroup $usergroup) {
|
public function addUserGroup(UserGroup $usergroup) {
|
||||||
|
// Si groupe lié à only
|
||||||
// Recherche de l'utilisateur eportail
|
if($usergroup->getGroup()->getIdonlyoffice()) {
|
||||||
|
if($this->authOnly()) {
|
||||||
// s'il existe
|
$respuser = \Unirest\Request::get($this->only_url.'/people/'.$usergroup->getUser()->getUsername(),$this->headers);
|
||||||
// Recherche du groupe
|
if(!$this->koresponse($respuser)) {
|
||||||
|
$query = array('userId' => $respuser->body->response->id);
|
||||||
// si le groupe existe
|
$body = \Unirest\Request\Body::json($query);
|
||||||
// Création du rattachement
|
$respsubmit = \Unirest\Request::post($this->only_url.'/project/'.$usergroup->getGroup()->getIdonlyoffice().'/team',$this->headers,$body);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue