Merge branch 'master' into dist/envole/6/master

This commit is contained in:
Arnaud Fornerot 2020-10-01 16:09:55 +02:00
commit b1d9c2dc63
5 changed files with 10 additions and 121 deletions

View File

@ -61,7 +61,7 @@ class TestRestCommand extends Command
// only = liste des informations désirés = user, items, bookmarks, groups, alerts, calendars // only = liste des informations désirés = user, items, bookmarks, groups, alerts, calendars
$apiurl = $url."/rest/user/".$login; $apiurl = $url."/rest/user/".$login;
$this->writeln($apiurl); $this->writeln($apiurl);
$response = \Unirest\Request::post($apiurl,$headers,["key"=>$masterapikey,"only"=>"user,calendars"]); $response = \Unirest\Request::post($apiurl,$headers,["key"=>$masterapikey,"only"=>"user,items,bookmarks"]);
dump($response->body); dump($response->body);
$this->writeln(''); $this->writeln('');

View File

@ -73,7 +73,7 @@ class RestController extends Controller
$itemcategorys=null; $itemcategorys=null;
$weburl="https://".$this->getParameter("weburl")."/".$this->getParameter("alias")."/"; $weburl="https://".$this->getParameter("weburl")."/".$this->getParameter("alias")."/";
$em->getRepository("CadolesPortalBundle:Item")->getUserItems($user,$bookmarks,$items,$itemcategorys,null,3); $em->getRepository("CadolesPortalBundle:Item")->getUserItems($user,$bookmarks,$items,$itemcategorys,null,4);
//$this->getDoctrine()->getRepository("CadolesPortalBundle:Page")->getPagesUser($user,null,$entity,$pagesuser,$pagesadmin,$groupsshared); //$this->getDoctrine()->getRepository("CadolesPortalBundle:Page")->getPagesUser($user,null,$entity,$pagesuser,$pagesadmin,$groupsshared);
// Construction de la réponse // Construction de la réponse
@ -95,6 +95,7 @@ class RestController extends Controller
$tmp["title"] = $bookmark->getTitle(); $tmp["title"] = $bookmark->getTitle();
$tmp["url"] = $bookmark->getUrl(); $tmp["url"] = $bookmark->getUrl();
$tmp["target"] = $bookmark->getTarget(); $tmp["target"] = $bookmark->getTarget();
$tmp["item"] = ($bookmark->getItem()?$bookmark->getItem()->getId():null);
$tmp["order"] = 0; $tmp["order"] = 0;
$tmp["color"] = "#".($bookmark->getColor()?$bookmark->getColor():$this->get('session')->get('color')["main"]); $tmp["color"] = "#".($bookmark->getColor()?$bookmark->getColor():$this->get('session')->get('color')["main"]);
$tmp["icon"] = $weburl.($bookmark->getIcon()?$bookmark->getIcon()->getLabel():"uploads/icon/icon_pin.png"); $tmp["icon"] = $weburl.($bookmark->getIcon()?$bookmark->getIcon()->getLabel():"uploads/icon/icon_pin.png");

View File

@ -573,121 +573,7 @@ class PagewidgetController extends Controller
// Profilage // Profilage
$user=$this->getUser(); $user=$this->getUser();
$roles=($user?$user->getRoles():["ROLE_ANONYME"]); $itemsordered = $em->getRepository("CadolesPortalBundle:Item")->getUserItems($user,$bookmarks,$items,$itemcategorys,$iditemcategory,$withbookmark);
$groups=($user?$user->getGroups():[]);
$niveau01=($user?$user->getNiveau01():[]);
// Bookmark de l'utilisateur
$bookmarks = array();
if($user)
$bookmarks=$em->getRepository("CadolesPortalBundle:Bookmark")->findBy(["user"=>$user]);
// Bookmark lié à un item
$bookmarksitems=new ArrayCollection();
foreach($bookmarks as $bookmark) {
if($bookmark->getItem()) $bookmarksitems->add($bookmark->getItem());
}
// Initialisation du calcul des items
$items=new ArrayCollection();
// Récupération des items par rôles
foreach($roles as $role) {
$qb = $em->createQueryBuilder();
$qb->select('item')
->from("CadolesPortalBundle:Item", 'item')
->where($qb->expr()->like('item.roles', $qb->expr()->literal("%$role%")));
if($iditemcategory && $itemcategoryfilter) {
$qb->andWhere("item.itemcategory=:itemcategory")
->setParameter("itemcategory",$itemcategoryfilter);
}
$itemsroles=$qb->getQuery()->getResult();
foreach($itemsroles as $itemrole) {
if($withbookmark==1) {
if(!$items->contains($itemrole)) $items->add($itemrole);
}
else {
if(!$bookmarksitems->contains($itemrole) && !$items->contains($itemrole)) $items->add($itemrole);
}
}
}
// Récupération des items par group
foreach($groups as $group) {
$qb = $em->createQueryBuilder();
$qb->select('item')
->from("CadolesPortalBundle:Item", 'item')
->where(":group MEMBER OF item.groups")
->setParameter("group",$group->getGroup());
if($iditemcategory && $itemcategoryfilter) {
$qb->andWhere("item.itemcategory=:itemcategory")
->setParameter("itemcategory",$itemcategoryfilter);
}
$itemsgroups=$qb->getQuery()->getResult();
foreach($itemsgroups as $itemgroup) {
if($withbookmark==1) {
if(!$items->contains($itemgroup)) $items->add($itemgroup);
}
else {
if(!$bookmarksitems->contains($itemgroup) && !$items->contains($itemgroup)) $items->add($itemgroup);
}
}
}
// Récupération des items par niveau01
if($niveau01) {
$qb = $em->createQueryBuilder();
$qb->select('item')
->from("CadolesPortalBundle:Item", 'item')
->where(":niveau01 MEMBER OF item.niveau01s")
->setParameter("niveau01",$niveau01);
if($iditemcategory && $itemcategoryfilter) {
$qb->andWhere("item.itemcategory=:itemcategory")
->setParameter("itemcategory",$itemcategoryfilter);
}
$itemsniveau01s=$qb->getQuery()->getResult();
foreach($itemsniveau01s as $itemniveau01) {
if($withbookmark==1) {
if(!$items->contains($itemniveau01)) $items->add($itemniveau01);
}
else {
if(!$bookmarksitems->contains($itemniveau01) && !$items->contains($itemniveau01)) $items->add($itemniveau01);
}
}
}
// Trie des items
$itemsordered = $items->getIterator();
$itemsordered->uasort(function ($first, $second) {
if((int) $first->getRowOrder() > (int) $second->getRowOrder())
$return=1;
elseif((int) $first->getRowOrder() == (int) $second->getRowOrder()) {
if($first->getTitle() > $second->getTitle())
$return=1;
else
$return=-1;
}
else
$return=-1;
return $return;
});
// Catégories affichées
$itemcategorys = $this->getDoctrine()->getRepository('CadolesPortalBundle:Itemcategory')->findBy([], ['rowOrder' => 'asc']);
if($iditemcategory && $itemcategoryfilter) $itemcategorys = $itemcategoryfilter;
switch($withbookmark) {
// items uniquement
case 1: $bookmarks=null; break;
// bookmarks uniquement
case 2: $itemsordered=null; break;
}
// Render // Render
return $this->render($this->labelentity.':viewitem.html.twig', [ return $this->render($this->labelentity.':viewitem.html.twig', [

View File

@ -13,8 +13,6 @@ class ItemRepository extends EntityRepository
$groups=($user?$user->getGroups():[]); $groups=($user?$user->getGroups():[]);
$niveau01=($user?$user->getNiveau01():[]); $niveau01=($user?$user->getNiveau01():[]);
// Bookmark de l'utilisateur // Bookmark de l'utilisateur
$bookmarks = array(); $bookmarks = array();
if($user) if($user)
@ -22,9 +20,11 @@ class ItemRepository extends EntityRepository
// Bookmark lié à un item // Bookmark lié à un item
$bookmarksitems=new ArrayCollection(); $bookmarksitems=new ArrayCollection();
if($withbookmark==0) {
foreach($bookmarks as $bookmark) { foreach($bookmarks as $bookmark) {
if($bookmark->getItem()) $bookmarksitems->add($bookmark->getItem()); if($bookmark->getItem()) $bookmarksitems->add($bookmark->getItem());
} }
}
// Initialisation du calcul des items // Initialisation du calcul des items
$items=new ArrayCollection(); $items=new ArrayCollection();
@ -114,5 +114,6 @@ class ItemRepository extends EntityRepository
} }
return $itemsordered;
} }
} }

View File

@ -5,4 +5,5 @@ firstname=givenName
lastname=sn lastname=sn
email=mail email=mail
user_groups=user_groups user_groups=user_groups
rne=rne