ne notifier que sur les messages des groupes de travail et non sur les groupes fonctionnels (fixes #34)

This commit is contained in:
afornerot 2019-11-08 16:21:08 +01:00
parent 3b0ac28df9
commit e553a9fdeb
1 changed files with 34 additions and 33 deletions

View File

@ -54,42 +54,43 @@ class CountMessageCommand extends Command
foreach($user->getGroups() as $usergroup) {
// On calcule le nombre de message non lu pour l'utilisateur'
$group=$usergroup->getGroup();
$qb = $this->em->createQueryBuilder();
$tm = $qb ->select($qb->expr()->count('m.id'))
->from('CadolesWebsocketBundle:Message', 'm')
->where('m.group = :group')
->andWhere('m.user != :user')
->setParameter('group', $group)
->setParameter('user', $user)
->getQuery()->getSingleScalarResult();
if($group->getFgcanshare()) {
$qb = $this->em->createQueryBuilder();
$tm = $qb ->select($qb->expr()->count('m.id'))
->from('CadolesWebsocketBundle:Message', 'm')
->where('m.group = :group')
->andWhere('m.user != :user')
->setParameter('group', $group)
->setParameter('user', $user)
->getQuery()->getSingleScalarResult();
$qb = $this->em->createQueryBuilder();
$tr = $qb ->select($qb->expr()->count('m.id'))
->from('CadolesWebsocketBundle:Message', 'm')
->where('m.group = :group')
->andWhere('m.user != :user')
->andWhere(':user MEMBER OF m.readers')
->setParameter('group', $group)
->setParameter('user', $user)
->getQuery()->getSingleScalarResult();
$qb = $this->em->createQueryBuilder();
$tr = $qb ->select($qb->expr()->count('m.id'))
->from('CadolesWebsocketBundle:Message', 'm')
->where('m.group = :group')
->andWhere('m.user != :user')
->andWhere(':user MEMBER OF m.readers')
->setParameter('group', $group)
->setParameter('user', $user)
->getQuery()->getSingleScalarResult();
if($tm-$tr>0) $cptnotread+=($tm-$tr);
if($tm-$tr>0) $cptnotread+=($tm-$tr);
}
if($cptnotread>0) {
$this->writeln($user->getUsername()." notifié de ".$cptnotread." messages non lus");
$template="template";
$mail_params=array(
"subject" => $this->appname." : Messages non lus",
"body_html"=>"<p>Vous avez ".$cptnotread." messages non lus sur ".$this->appname."</p><p>Vous pouvez les consulter sur <a href='".$this->url."'>".$this->url."</a></p>",
"body_text"=>"Vous avez ".$cptnotread." messages non lus sur ".$this->appname."\nVous pouvez les consulter sur ".$this->url,
);
$message = $this->container->get('cadoles.core.service.mail');
$message->sendEmail($template, $mail_params, $user->getEmail(), $this->noreply, $this->appname);
}
}
if($cptnotread>0) {
$this->writeln($user->getUsername()." notifié de ".$cptnotread." messages non lus");
$template="template";
$mail_params=array(
"subject" => $this->appname." : Messages non lus",
"body_html"=>"<p>Vous avez ".$cptnotread." messages non lus sur ".$this->appname."</p><p>Vous pouvez les consulter sur <a href='".$this->url."'>".$this->url."</a></p>",
"body_text"=>"Vous avez ".$cptnotread." messages non lus sur ".$this->appname."\nVous pouvez les consulter sur ".$this->url,
);
$message = $this->container->get('cadoles.core.service.mail');
$message->sendEmail($template, $mail_params, $user->getEmail(), $this->noreply, $this->appname);
}
}
$this->writeln('');
return 1;