ajout compteur visite utilisateur (ref #150)
This commit is contained in:
parent
dc13f8a388
commit
e18790790b
|
@ -156,6 +156,12 @@ class SecurityController extends Controller
|
|||
$dispatcher = new EventDispatcher();
|
||||
$dispatcher->dispatch("security.interactive_login", $event);
|
||||
|
||||
// On enregistre sa visite
|
||||
$user->setVisitedate(new \DateTime());
|
||||
$user->setVisitecpt($user->getVisitecpt()+1);
|
||||
$em->persist($user);
|
||||
$em->flush();
|
||||
|
||||
if($redirect)
|
||||
return $this->redirect($redirect);
|
||||
else
|
||||
|
|
|
@ -203,65 +203,93 @@ class ConfigController extends Controller
|
|||
$session=$this->get('session');
|
||||
$config=$em->getRepository('CadolesCoreBundle:Config')->find("datauser");
|
||||
$fields=$config->getValue();
|
||||
$fields=json_decode($fields,true);
|
||||
if(!is_array($fields)) $fields=[];
|
||||
|
||||
if($fields=="") {
|
||||
// Valeur par défaut 0=caché / 1=falcultatif / 2=obligatoire
|
||||
// Valeur par défaut 0=caché / 1=falcultatif / 2=obligatoire
|
||||
if(!array_key_exists("firstname",$fields)) {
|
||||
$fields["firstname"]["perm"]=1;
|
||||
$fields["firstname"]["label"]="Prénom";
|
||||
}
|
||||
|
||||
if(!array_key_exists("visible",$fields)) {
|
||||
$fields["visible"]["perm"]=2;
|
||||
$fields["visible"]["label"]="Visible";
|
||||
}
|
||||
|
||||
if(!array_key_exists("authlevel",$fields)) {
|
||||
$fields["authlevel"]["perm"]=2;
|
||||
$fields["authlevel"]["label"]="Niveau d'authentification";
|
||||
}
|
||||
|
||||
if(!array_key_exists("belongingpopulation",$fields)) {
|
||||
$fields["belongingpopulation"]["perm"]=2;
|
||||
$fields["belongingpopulation"]["label"]="Population d'appartenance";
|
||||
}
|
||||
|
||||
if(!array_key_exists("job",$fields)) {
|
||||
$fields["job"]["perm"]=1;
|
||||
$fields["job"]["label"]="Métier";
|
||||
}
|
||||
|
||||
if(!array_key_exists("position",$fields)) {
|
||||
$fields["position"]["perm"]=1;
|
||||
$fields["position"]["label"]="Fonction";
|
||||
}
|
||||
|
||||
if(!array_key_exists("niveau02",$fields)) {
|
||||
$fields["niveau02"]["perm"]=1;
|
||||
$fields["niveau02"]["label"]="Niveau 02";
|
||||
$fields["niveau02"]["label"]=$session->get('labelniveau02');
|
||||
}
|
||||
|
||||
if(!array_key_exists("usualname",$fields)) {
|
||||
$fields["usualname"]["perm"]=1;
|
||||
$fields["usualname"]["label"]="Nom d'Usage";
|
||||
}
|
||||
|
||||
if(!array_key_exists("gender",$fields)) {
|
||||
$fields["gender"]["perm"]=1;
|
||||
$fields["gender"]["label"]="Sexe";
|
||||
}
|
||||
|
||||
if(!array_key_exists("givensname",$fields)) {
|
||||
$fields["givensname"]["perm"]=1;
|
||||
$fields["givensname"]["label"]="Autre Prénom";
|
||||
}
|
||||
|
||||
if(!array_key_exists("telephonenumber",$fields)) {
|
||||
$fields["telephonenumber"]["perm"]=1;
|
||||
$fields["telephonenumber"]["label"]="Téléphone";
|
||||
}
|
||||
|
||||
if(!array_key_exists("postaladress",$fields)) {
|
||||
$fields["postaladress"]["perm"]=1;
|
||||
$fields["postaladress"]["label"]="Adresse";
|
||||
}
|
||||
|
||||
if(!array_key_exists("birthdate",$fields)) {
|
||||
$fields["birthdate"]["perm"]=1;
|
||||
$fields["birthdate"]["label"]="Date de Naissance";
|
||||
}
|
||||
|
||||
if(!array_key_exists("birthcountry",$fields)) {
|
||||
$fields["birthcountry"]["perm"]=1;
|
||||
$fields["birthcountry"]["label"]="Pays de Naissance";
|
||||
}
|
||||
|
||||
if(!array_key_exists("birthplace",$fields)) {
|
||||
$fields["birthplace"]["perm"]=1;
|
||||
$fields["birthplace"]["label"]="Ville de Naissance";
|
||||
}
|
||||
else {
|
||||
$fields=json_decode($fields, true);
|
||||
|
||||
if(!array_key_exists("visite",$fields)) {
|
||||
$fields["visite"]["perm"]=1;
|
||||
$fields["visite"]["label"]="Visite";
|
||||
}
|
||||
|
||||
if($session->get('viewniveau02')&&!array_key_exists("niveau02",$fields))
|
||||
$fields["niveau02"]["perm"]=1;
|
||||
elseif(!$session->get('viewniveau02'))
|
||||
if(!$session->get('viewniveau02'))
|
||||
unset($fields["niveau02"]);
|
||||
|
||||
if(array_key_exists("niveau02",$fields))
|
||||
$fields["niveau02"]["label"]=$session->get('labelniveau02');
|
||||
|
||||
|
||||
|
||||
|
@ -311,59 +339,66 @@ class ConfigController extends Controller
|
|||
$config=$em->getRepository('CadolesCoreBundle:Config')->find("datausers");
|
||||
$fields=$config->getValue();
|
||||
|
||||
if($fields=="") {
|
||||
// Valeur par défaut 0=caché / 3=visible
|
||||
$fields=json_decode($fields, true);
|
||||
if(!is_array($fields)) $fields=[];
|
||||
|
||||
// Valeur par défaut 0=caché / 3=visible
|
||||
if(!array_key_exists("avatar",$fields)) {
|
||||
$fields["avatar"]["perm"]=1;
|
||||
$fields["avatar"]["label"]="Avatar";
|
||||
|
||||
}
|
||||
if(!array_key_exists("login",$fields)) {
|
||||
$fields["login"]["perm"]=1;
|
||||
$fields["login"]["label"]="Login";
|
||||
|
||||
}
|
||||
if(!array_key_exists("lastname",$fields)) {
|
||||
$fields["lastname"]["perm"]=1;
|
||||
$fields["lastname"]["label"]="Nom";
|
||||
|
||||
}
|
||||
if(!array_key_exists("firstname",$fields)) {
|
||||
$fields["firstname"]["perm"]=1;
|
||||
$fields["firstname"]["label"]="Prenom";
|
||||
|
||||
}
|
||||
if(!array_key_exists("email",$fields)) {
|
||||
$fields["email"]["perm"]=1;
|
||||
$fields["email"]["label"]="Email";
|
||||
|
||||
}
|
||||
if(!array_key_exists("niveau01",$fields)) {
|
||||
$fields["niveau01"]["perm"]=1;
|
||||
$fields["niveau01"]["label"]="Niveau 01";
|
||||
|
||||
$fields["niveau01"]["label"]=$session->get('labelniveau01');
|
||||
}
|
||||
if(!array_key_exists("niveau02",$fields)) {
|
||||
$fields["niveau02"]["perm"]=1;
|
||||
$fields["niveau02"]["label"]="Niveau 02";
|
||||
|
||||
$fields["niveau02"]["label"]=$session->get('labelniveau02');
|
||||
}
|
||||
if(!array_key_exists("group",$fields)) {
|
||||
$fields["group"]["perm"]=1;
|
||||
$fields["group"]["label"]="Groupes";
|
||||
|
||||
}
|
||||
if(!array_key_exists("job",$fields)) {
|
||||
$fields["job"]["perm"]=1;
|
||||
$fields["job"]["label"]="Métier";
|
||||
|
||||
}
|
||||
if(!array_key_exists("position",$fields)) {
|
||||
$fields["position"]["perm"]=1;
|
||||
$fields["position"]["label"]="Fonction";
|
||||
|
||||
}
|
||||
if(!array_key_exists("role",$fields)) {
|
||||
$fields["role"]["perm"]=1;
|
||||
$fields["role"]["label"]="Rôles";
|
||||
|
||||
}
|
||||
if(!array_key_exists("telephonenumber",$fields)) {
|
||||
$fields["telephonenumber"]["perm"]=1;
|
||||
$fields["telephonenumber"]["label"]="Téléphone";
|
||||
}
|
||||
else {
|
||||
$fields=json_decode($fields, true);
|
||||
if(!array_key_exists("visitedate",$fields)) {
|
||||
$fields["visitedate"]["perm"]=1;
|
||||
$fields["visitedate"]["label"]="Visite";
|
||||
}
|
||||
|
||||
$fields["niveau01"]["label"]=$session->get('labelniveau01');
|
||||
if($session->get('viewniveau02')&&!array_key_exists("niveau02",$fields))
|
||||
$fields["niveau02"]["perm"]=1;
|
||||
elseif(!$session->get('viewniveau02'))
|
||||
if(!$session->get('viewniveau02'))
|
||||
unset($fields["niveau02"]);
|
||||
|
||||
if(array_key_exists("niveau02",$fields))
|
||||
$fields["niveau02"]["label"]=$session->get('labelniveau02');
|
||||
|
||||
|
||||
|
||||
$form = $this->createForm(DatauserType::class,$config,array("mode"=>"datausers","fields" => $fields));
|
||||
|
||||
// Récupération des data du formulaire
|
||||
|
|
|
@ -102,7 +102,6 @@ class CoreController extends Controller
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($toprofil) {
|
||||
return $this->redirect($this->generateUrl('cadoles_core_user',array("info"=>"Merci de compléter votre profil")));
|
||||
}
|
||||
|
|
|
@ -225,6 +225,10 @@ class UserController extends Controller
|
|||
break;
|
||||
|
||||
case 12 :
|
||||
$qb->orderBy('user.visitedate',$order[0]["dir"]);
|
||||
break;
|
||||
|
||||
case 13 :
|
||||
$qb->orderBy('user.role',$order[0]["dir"]);
|
||||
break;
|
||||
}
|
||||
|
@ -264,6 +268,10 @@ class UserController extends Controller
|
|||
break;
|
||||
|
||||
case 10 :
|
||||
$qb->orderBy('user.visitedate',$order[0]["dir"]);
|
||||
break;
|
||||
|
||||
case 11 :
|
||||
$qb->orderBy('user.role',$order[0]["dir"]);
|
||||
break;
|
||||
}
|
||||
|
@ -300,6 +308,7 @@ class UserController extends Controller
|
|||
array_push($tmp,$groups);
|
||||
array_push($tmp,$data->getJob());
|
||||
array_push($tmp,$data->getPosition());
|
||||
array_push($tmp,($data->getVisitedate()?$data->getVisitedate()->format("d/m/Y H:i")."<br>nb = ".$data->getVisitecpt():""));
|
||||
array_push($tmp,$data->getRole());
|
||||
|
||||
array_push($output["data"],$tmp);
|
||||
|
@ -1147,55 +1156,88 @@ class UserController extends Controller
|
|||
$config=$em->getRepository('CadolesCoreBundle:Config')->find("datauser");
|
||||
$fields=$config->getValue();
|
||||
$fields=json_decode($fields,true);
|
||||
if(!is_array($fields)) $fields=[];
|
||||
|
||||
if($fields=="") {
|
||||
// Valeur par défaut 0=caché / 1=falcultatif / 2=obligatoire
|
||||
// Valeur par défaut 0=caché / 1=falcultatif / 2=obligatoire
|
||||
if(!array_key_exists("firstname",$fields)) {
|
||||
$fields["firstname"]["perm"]=1;
|
||||
$fields["firstname"]["label"]="Prénom";
|
||||
}
|
||||
|
||||
if(!array_key_exists("visible",$fields)) {
|
||||
$fields["visible"]["perm"]=2;
|
||||
$fields["visible"]["label"]="Visible";
|
||||
}
|
||||
|
||||
if(!array_key_exists("authlevel",$fields)) {
|
||||
$fields["authlevel"]["perm"]=2;
|
||||
$fields["authlevel"]["label"]="Niveau d'authentification";
|
||||
}
|
||||
|
||||
if(!array_key_exists("belongingpopulation",$fields)) {
|
||||
$fields["belongingpopulation"]["perm"]=2;
|
||||
$fields["belongingpopulation"]["label"]="Population d'appartenance";
|
||||
}
|
||||
|
||||
if(!array_key_exists("job",$fields)) {
|
||||
$fields["job"]["perm"]=1;
|
||||
$fields["job"]["label"]="Métier";
|
||||
}
|
||||
|
||||
if(!array_key_exists("position",$fields)) {
|
||||
$fields["position"]["perm"]=1;
|
||||
$fields["position"]["label"]="Fonction";
|
||||
}
|
||||
|
||||
if(!array_key_exists("niveau02",$fields)) {
|
||||
$fields["niveau02"]["perm"]=1;
|
||||
$fields["niveau02"]["label"]="Niveau 02";
|
||||
}
|
||||
|
||||
if(!array_key_exists("usualname",$fields)) {
|
||||
$fields["usualname"]["perm"]=1;
|
||||
$fields["usualname"]["label"]="Nom d'Usage";
|
||||
}
|
||||
|
||||
if(!array_key_exists("gender",$fields)) {
|
||||
$fields["gender"]["perm"]=1;
|
||||
$fields["gender"]["label"]="Sexe";
|
||||
}
|
||||
|
||||
if(!array_key_exists("givensname",$fields)) {
|
||||
$fields["givensname"]["perm"]=1;
|
||||
$fields["givensname"]["label"]="Autre Prénom";
|
||||
}
|
||||
|
||||
if(!array_key_exists("telephonenumber",$fields)) {
|
||||
$fields["telephonenumber"]["perm"]=1;
|
||||
$fields["telephonenumber"]["label"]="Téléphone";
|
||||
}
|
||||
|
||||
if(!array_key_exists("postaladress",$fields)) {
|
||||
$fields["postaladress"]["perm"]=1;
|
||||
$fields["postaladress"]["label"]="Adresse";
|
||||
}
|
||||
|
||||
if(!array_key_exists("birthdate",$fields)) {
|
||||
$fields["birthdate"]["perm"]=1;
|
||||
$fields["birthdate"]["label"]="Date de Naissance";
|
||||
}
|
||||
|
||||
if(!array_key_exists("birthcountry",$fields)) {
|
||||
$fields["birthcountry"]["perm"]=1;
|
||||
$fields["birthcountry"]["label"]="Pays de Naissance";
|
||||
}
|
||||
|
||||
if(!array_key_exists("birthplace",$fields)) {
|
||||
$fields["birthplace"]["perm"]=1;
|
||||
$fields["birthplace"]["label"]="Ville de Naissance";
|
||||
}
|
||||
|
||||
if(!array_key_exists("visite",$fields)) {
|
||||
$fields["visite"]["perm"]=1;
|
||||
$fields["visite"]["label"]="Visite";
|
||||
}
|
||||
return $fields;
|
||||
}
|
||||
|
||||
|
|
|
@ -163,6 +163,16 @@ class User implements UserInterface, \Serializable
|
|||
*/
|
||||
private $viewcalendar;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime", nullable=true)
|
||||
*/
|
||||
private $visitedate;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="integer", nullable=true)
|
||||
*/
|
||||
private $visitecpt;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Country", inversedBy="users")
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
|
@ -1796,4 +1806,52 @@ class User implements UserInterface, \Serializable
|
|||
{
|
||||
return $this->projectcomments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set visitedate
|
||||
*
|
||||
* @param \DateTime $visitedate
|
||||
*
|
||||
* @return User
|
||||
*/
|
||||
public function setVisitedate($visitedate)
|
||||
{
|
||||
$this->visitedate = $visitedate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get visitedate
|
||||
*
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getVisitedate()
|
||||
{
|
||||
return $this->visitedate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set visitecpt
|
||||
*
|
||||
* @param integer $visitecpt
|
||||
*
|
||||
* @return User
|
||||
*/
|
||||
public function setVisitecpt($visitecpt)
|
||||
{
|
||||
$this->visitecpt = $visitecpt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get visitecpt
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getVisitecpt()
|
||||
{
|
||||
return $this->visitecpt;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -282,6 +282,19 @@
|
|||
$session->set("sublogo", $niveau01->getLogo());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if($curentuser!="anon.") {
|
||||
$visitedate=$curentuser->getVisitedate();
|
||||
$visitedate->add(new \DateInterval("PT1H"));
|
||||
$now=new \DateTime();
|
||||
if($visitedate<$now) {
|
||||
$curentuser->setVisitedate($now);
|
||||
$curentuser->setVisitecpt($curentuser->getVisitecpt()+1);
|
||||
$this->em->persist($curentuser);
|
||||
$this->em->flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@ use Symfony\Component\Form\Extension\Core\Type\ButtonType;
|
|||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\DateType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Tetranz\Select2EntityBundle\Form\Type\Select2EntityType;
|
||||
|
||||
|
@ -360,6 +362,22 @@ class UserType extends AbstractType
|
|||
}
|
||||
}
|
||||
|
||||
if(!array_key_exists("visite",$fields)) $fields["visite"]["perm"]==2;
|
||||
if($fields["visite"]["perm"]!=0) {
|
||||
$builder->add('visitedate', DateTimeType::class, [
|
||||
"label" => 'Date de dernière visite',
|
||||
"disabled" => true,
|
||||
"required" => ($fields["visite"]["perm"]==2),
|
||||
"widget" => 'single_text',
|
||||
]);
|
||||
|
||||
$builder->add('visitecpt', IntegerType::class, [
|
||||
"label" => 'Nombre de visites',
|
||||
"required" => ($fields["visite"]["perm"]==2),
|
||||
"disabled" => true,
|
||||
]);
|
||||
}
|
||||
|
||||
# Avatar
|
||||
$builder->add('avatar',HiddenType::class, array("empty_data" => "noavatar.png"));
|
||||
|
||||
|
|
|
@ -261,6 +261,20 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if form.visitedate is defined %}
|
||||
<div id="panelvisite" class="panel panel-primary">
|
||||
<div class="panel-heading">
|
||||
<i class="fa fa-user fa-fw"></i> Visite
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
{{ form_row(form.visitedate) }}
|
||||
{{ form_row(form.visitecpt) }}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -366,13 +380,15 @@
|
|||
|
||||
{% block localjavascript %}
|
||||
$(document).ready(function() {
|
||||
{% if access=="profil" %}
|
||||
{% if access=="user" %}
|
||||
{% set color = app.session.get('color') %}
|
||||
$(".sidebar").remove();
|
||||
$("body").removeClass("body");
|
||||
$("body").addClass("simple");
|
||||
$("body").attr('style', 'background-color: #{{ color['colorbody'] }} !important');
|
||||
$("#page-wrapper").css("margin","auto");
|
||||
$("#page-wrapper").css("max-width","1000px");
|
||||
$("#page-wrapper").css("border-left","none");
|
||||
|
||||
{% endif %}
|
||||
|
||||
// Vider le password
|
||||
|
|
|
@ -45,6 +45,7 @@ td { font-size: 10px; }
|
|||
<th class="no-sort {% if fields["group"] is defined and fields["group"].perm==0 %}no-visible{% endif %}">Groupes</th>
|
||||
<th class="{% if fields["job"] is defined and fields["job"].perm==0 %}no-visible{% endif %}">Métier</th>
|
||||
<th class="{% if fields["position"] is defined and fields["position"].perm==0 %}no-visible{% endif %}">Fonction</th>
|
||||
<th class="{% if fields["visitedate"] is defined and fields["visitedate"].perm==0 %}no-visible{% endif %}">Visite</th>
|
||||
<th class="{% if fields["role"] is defined and fields["role"].perm==0 %}no-visible{% endif %}">Rôle</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
|
|
@ -18,8 +18,10 @@
|
|||
{%if viewniveau02 and user.niveau02%}<b>{{ labelniveau02 }}</b> = {{ user.niveau02.label }}<br>{% endif %}
|
||||
{%if user.job %}<b>Métier</b> = {{ user.job }}<br>{%endif%}
|
||||
{%if user.position %}<b>Fonction</b> = {{ user.position }}<br>{%endif%}
|
||||
{%if user.postaladress %}<b>Adresse</b> = {{ user.postaladress }}<br><br>{%endif%}
|
||||
|
||||
{%if user.postaladress %}<b>Adresse</b> = {{ user.postaladress }}<br>{%endif%}
|
||||
{%if user.visitedate %}<b>Date de dernière visite</b> = {{ user.visitedate|date("d/m/Y H:i") }}<br>{%endif%}
|
||||
{%if user.visitecpt %}<b>Nombre de visites</b> = {{ user.visitecpt }}<br>{%endif%}
|
||||
<br>
|
||||
{% set fgtitle=false %}
|
||||
{% for usergroup in user.groups %}
|
||||
{% if usergroup.group.fgcanshare %}
|
||||
|
|
Loading…
Reference in New Issue