ne notifier que sur les messages des groupes de travail et non sur les groupes fonctionnels (fixes #34)
This commit is contained in:
parent
3b0ac28df9
commit
e553a9fdeb
|
@ -54,42 +54,43 @@ class CountMessageCommand extends Command
|
||||||
foreach($user->getGroups() as $usergroup) {
|
foreach($user->getGroups() as $usergroup) {
|
||||||
// On calcule le nombre de message non lu pour l'utilisateur'
|
// On calcule le nombre de message non lu pour l'utilisateur'
|
||||||
$group=$usergroup->getGroup();
|
$group=$usergroup->getGroup();
|
||||||
$qb = $this->em->createQueryBuilder();
|
if($group->getFgcanshare()) {
|
||||||
$tm = $qb ->select($qb->expr()->count('m.id'))
|
$qb = $this->em->createQueryBuilder();
|
||||||
->from('CadolesWebsocketBundle:Message', 'm')
|
$tm = $qb ->select($qb->expr()->count('m.id'))
|
||||||
->where('m.group = :group')
|
->from('CadolesWebsocketBundle:Message', 'm')
|
||||||
->andWhere('m.user != :user')
|
->where('m.group = :group')
|
||||||
->setParameter('group', $group)
|
->andWhere('m.user != :user')
|
||||||
->setParameter('user', $user)
|
->setParameter('group', $group)
|
||||||
->getQuery()->getSingleScalarResult();
|
->setParameter('user', $user)
|
||||||
|
->getQuery()->getSingleScalarResult();
|
||||||
|
|
||||||
$qb = $this->em->createQueryBuilder();
|
$qb = $this->em->createQueryBuilder();
|
||||||
$tr = $qb ->select($qb->expr()->count('m.id'))
|
$tr = $qb ->select($qb->expr()->count('m.id'))
|
||||||
->from('CadolesWebsocketBundle:Message', 'm')
|
->from('CadolesWebsocketBundle:Message', 'm')
|
||||||
->where('m.group = :group')
|
->where('m.group = :group')
|
||||||
->andWhere('m.user != :user')
|
->andWhere('m.user != :user')
|
||||||
->andWhere(':user MEMBER OF m.readers')
|
->andWhere(':user MEMBER OF m.readers')
|
||||||
->setParameter('group', $group)
|
->setParameter('group', $group)
|
||||||
->setParameter('user', $user)
|
->setParameter('user', $user)
|
||||||
->getQuery()->getSingleScalarResult();
|
->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('');
|
$this->writeln('');
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Reference in New Issue