prefence user
This commit is contained in:
parent
ea2af3b861
commit
8f2e412b60
|
@ -28,40 +28,67 @@ class FileController extends Controller
|
||||||
$sort=$request->get("sort");
|
$sort=$request->get("sort");
|
||||||
$defaultview=$request->get("defaultview");
|
$defaultview=$request->get("defaultview");
|
||||||
|
|
||||||
// Récupérer en session le dernier subdirectory visité
|
// Récupérer les préférences utilisateur
|
||||||
$sessionsubdirectory = $this->get('session')->get('sessionsubdirectory');
|
$toupdate=false;
|
||||||
if(!is_array($sessionsubdirectory)) $sessionsubdirectory=[];
|
$preference=$this->getUser()->getPreference();
|
||||||
|
if(is_null($preference)) $preference=[];
|
||||||
|
|
||||||
if($clear) {
|
// Préférence subdirectory
|
||||||
if(array_key_exists($directory,$sessionsubdirectory)) unset($sessionsubdirectory[$directory]);
|
if(!array_key_exists("widgetsubdirectory",$preference)) {
|
||||||
$this->get('session')->set('sessionsubdirectory',$sessionsubdirectory);
|
$toupdate=true;
|
||||||
|
$preference["widgetsubdirectory"]=[];
|
||||||
|
}
|
||||||
|
if((!array_key_exists($directory,$preference["widgetsubdirectory"]))) {
|
||||||
|
$toupdate=true;
|
||||||
|
$preference["widgetsubdirectory"][$directory]=null;
|
||||||
|
}
|
||||||
|
if($clear&&!is_null($preference["widgetsubdirectory"][$directory])) {
|
||||||
|
$toupdate=true;
|
||||||
|
$preference["widgetsubdirectory"][$directory]=null;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(!$subdirectory) {
|
if(!$subdirectory) $subdirectory = $preference["widgetsubdirectory"][$directory];
|
||||||
if(array_key_exists($directory,$sessionsubdirectory)) $subdirectory=$sessionsubdirectory[$directory];
|
elseif($subdirectory!=$preference["widgetsubdirectory"][$directory]) {
|
||||||
}
|
$toupdate=true;
|
||||||
else {
|
$preference["widgetsubdirectory"][$directory] = $subdirectory;
|
||||||
$sessionsubdirectory[$directory] = $subdirectory;
|
|
||||||
$this->get('session')->set('sessionsubdirectory',$sessionsubdirectory);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Récupérer en session le mode de visualisation
|
// Préférence mode de visualisation
|
||||||
$sessionviewdirectory = $this->get('session')->get('sessionviewdirectory');
|
if(!array_key_exists("widgetviewdirectory",$preference)) {
|
||||||
if(!is_array($sessionviewdirectory)) $sessionviewdirectory=[$directory=>$defaultview];
|
$toupdate=true;
|
||||||
if(!array_key_exists($directory,$sessionviewdirectory)) $sessionviewdirectory[$directory]=$defaultview;
|
$preference["widgetviewdirectory"]=[];
|
||||||
if($view)
|
}
|
||||||
$sessionviewdirectory[$directory] = $view;
|
if((!array_key_exists($directory,$preference["widgetviewdirectory"]))) {
|
||||||
$this->get('session')->set('sessionviewdirectory',$sessionviewdirectory);
|
$toupdate=true;
|
||||||
|
$preference["widgetviewdirectory"][$directory]=$defaultview;
|
||||||
// Récupérer en session le trie
|
}
|
||||||
$sessionviewsort = $this->get('session')->get('sessionviewsort');
|
if($view&&$preference["widgetviewdirectory"][$directory]!=$view) {
|
||||||
if(!is_array($sessionviewsort)) $sessionviewsort=[$sort=>"name"];
|
$toupdate=true;
|
||||||
if(!array_key_exists($directory,$sessionviewsort)) $sessionviewsort[$directory]="name";
|
$preference["widgetviewdirectory"][$directory]=$view;
|
||||||
if($sort)
|
}
|
||||||
$sessionviewsort[$directory] = $sort;
|
|
||||||
$this->get('session')->set('sessionviewsort',$sessionviewsort);
|
|
||||||
|
|
||||||
|
// Prérence trie
|
||||||
|
if(!array_key_exists("widgetsortdirectory",$preference)) {
|
||||||
|
$toupdate=true;
|
||||||
|
$preference["widgetsortdirectory"]=[];
|
||||||
|
}
|
||||||
|
if((!array_key_exists($directory,$preference["widgetsortdirectory"]))) {
|
||||||
|
$toupdate=true;
|
||||||
|
$preference["widgetsortdirectory"][$directory]="name";
|
||||||
|
}
|
||||||
|
if($sort&&$preference["widgetsortdirectory"][$directory]!=$sort) {
|
||||||
|
$toupdate=true;
|
||||||
|
$preference["widgetsortdirectory"][$directory]=$sort;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mise à jour des préferences
|
||||||
|
if($toupdate) {
|
||||||
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
$this->getUser()->setPreference($preference);
|
||||||
|
$em->persist($this->getUser());
|
||||||
|
$em->flush();
|
||||||
|
}
|
||||||
|
|
||||||
// Construire le chemin réel
|
// Construire le chemin réel
|
||||||
$iddirectory=explode("-",$directory)[1];
|
$iddirectory=explode("-",$directory)[1];
|
||||||
|
@ -122,10 +149,10 @@ class FileController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
// Trie du tableu
|
// Trie du tableu
|
||||||
$sort = array_column($files, $sessionviewsort[$directory]);
|
$sort = array_column($files, $preference["widgetsortdirectory"][$directory]);
|
||||||
array_multisort($sort, SORT_ASC, $files);
|
array_multisort($sort, SORT_ASC, $files);
|
||||||
|
|
||||||
$sort = array_column($dirs, $sessionviewsort[$directory]);
|
$sort = array_column($dirs, $preference["widgetsortdirectory"][$directory]);
|
||||||
array_multisort($sort, SORT_ASC, $dirs);
|
array_multisort($sort, SORT_ASC, $dirs);
|
||||||
|
|
||||||
return $this->render('CadolesCoreBundle:File:list.html.twig',[
|
return $this->render('CadolesCoreBundle:File:list.html.twig',[
|
||||||
|
@ -142,8 +169,8 @@ class FileController extends Controller
|
||||||
'files' => $files,
|
'files' => $files,
|
||||||
'canupdate' => $canupdate,
|
'canupdate' => $canupdate,
|
||||||
'canadd' => $canupdate,
|
'canadd' => $canupdate,
|
||||||
'view' => $sessionviewdirectory[$directory],
|
'view' => $preference["widgetviewdirectory"][$directory],
|
||||||
'sort' => $sessionviewsort[$directory],
|
'sort' => $preference["widgetsortdirectory"][$directory],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,7 @@ class Registration implements UserInterface, \Serializable
|
||||||
private $niveau01other;
|
private $niveau01other;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(name="description", type="text", nullable=true)
|
* @ORM\Column(name="motivation", type="text", nullable=true)
|
||||||
*/
|
*/
|
||||||
private $motivation;
|
private $motivation;
|
||||||
|
|
||||||
|
|
|
@ -179,10 +179,15 @@ class User implements UserInterface, \Serializable
|
||||||
private $niveau01other;
|
private $niveau01other;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(name="description", type="text", nullable=true)
|
* @ORM\Column(name="motivation", type="text", nullable=true)
|
||||||
*/
|
*/
|
||||||
private $motivation;
|
private $motivation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(name="preference", type="array", nullable=true)
|
||||||
|
*/
|
||||||
|
private $preference;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity="Country", inversedBy="users")
|
* @ORM\ManyToOne(targetEntity="Country", inversedBy="users")
|
||||||
* @ORM\JoinColumn(nullable=true)
|
* @ORM\JoinColumn(nullable=true)
|
||||||
|
@ -1952,4 +1957,28 @@ class User implements UserInterface, \Serializable
|
||||||
{
|
{
|
||||||
return $this->motivation;
|
return $this->motivation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set preference
|
||||||
|
*
|
||||||
|
* @param array $preference
|
||||||
|
*
|
||||||
|
* @return User
|
||||||
|
*/
|
||||||
|
public function setPreference($preference)
|
||||||
|
{
|
||||||
|
$this->preference = $preference;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get preference
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getPreference()
|
||||||
|
{
|
||||||
|
return $this->preference;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,9 +73,9 @@
|
||||||
<a href="{{ path('cadoles_core_'~access~'_file_list',{'directory':directory,'clear':true,'sort':action }) }}" type="button" class="btn btn-primary">
|
<a href="{{ path('cadoles_core_'~access~'_file_list',{'directory':directory,'clear':true,'sort':action }) }}" type="button" class="btn btn-primary">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if sort=="name" %}
|
{% if sort=="name" %}
|
||||||
<i class="fas fa-sort-alpha-down"></i>
|
<i class="fas fa-long-arrow-alt-down"></i> Nom
|
||||||
{% else %}
|
{% else %}
|
||||||
<i class="fas fa-sort-numeric-down"></i>
|
<i class="fas fa-long-arrow-alt-down"></i> Date
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -26,33 +26,70 @@ class FrameController extends Controller
|
||||||
$subdirectory=$request->get("subdirectory");
|
$subdirectory=$request->get("subdirectory");
|
||||||
$clear=$request->get("clear");
|
$clear=$request->get("clear");
|
||||||
$view=$request->get("view");
|
$view=$request->get("view");
|
||||||
|
$sort=$request->get("sort");
|
||||||
$defaultview=$request->get("defaultview");
|
$defaultview=$request->get("defaultview");
|
||||||
|
|
||||||
// Récupérer en session le dernier subdirectory visité
|
// Récupérer les préférences utilisateur
|
||||||
$sessionsubdirectory = $this->get('session')->get('sessionsubdirectory');
|
$toupdate=false;
|
||||||
if(!is_array($sessionsubdirectory)) $sessionsubdirectory=[];
|
$preference=$this->getUser()->getPreference();
|
||||||
|
if(is_null($preference)) $preference=[];
|
||||||
|
|
||||||
if($clear) {
|
// Préférence subdirectory
|
||||||
if(array_key_exists($directory,$sessionsubdirectory)) unset($sessionsubdirectory[$directory]);
|
if(!array_key_exists("widgetsubdirectory",$preference)) {
|
||||||
$this->get('session')->set('sessionsubdirectory',$sessionsubdirectory);
|
$toupdate=true;
|
||||||
|
$preference["widgetsubdirectory"]=[];
|
||||||
|
}
|
||||||
|
if((!array_key_exists($directory,$preference["widgetsubdirectory"]))) {
|
||||||
|
$toupdate=true;
|
||||||
|
$preference["widgetsubdirectory"][$directory]=null;
|
||||||
|
}
|
||||||
|
if($clear&&!is_null($preference["widgetsubdirectory"][$directory])) {
|
||||||
|
$toupdate=true;
|
||||||
|
$preference["widgetsubdirectory"][$directory]=null;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(!$subdirectory) {
|
if(!$subdirectory) $subdirectory = $preference["widgetsubdirectory"][$directory];
|
||||||
if(array_key_exists($directory,$sessionsubdirectory)) $subdirectory=$sessionsubdirectory[$directory];
|
elseif($subdirectory!=$preference["widgetsubdirectory"][$directory]) {
|
||||||
}
|
$toupdate=true;
|
||||||
else {
|
$preference["widgetsubdirectory"][$directory] = $subdirectory;
|
||||||
$sessionsubdirectory[$directory] = $subdirectory;
|
|
||||||
$this->get('session')->set('sessionsubdirectory',$sessionsubdirectory);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Récupérer en session le mode de visualisation
|
// Préférence mode de visualisation
|
||||||
$sessionviewdirectory = $this->get('session')->get('sessionviewdirectory');
|
if(!array_key_exists("widgetviewdirectory",$preference)) {
|
||||||
if(!is_array($sessionviewdirectory)) $sessionviewdirectory=[$directory=>$defaultview];
|
$toupdate=true;
|
||||||
if(!array_key_exists($directory,$sessionviewdirectory)) $sessionviewdirectory[$directory]=$defaultview;
|
$preference["widgetviewdirectory"]=[];
|
||||||
if($view)
|
}
|
||||||
$sessionviewdirectory[$directory] = $view;
|
if((!array_key_exists($directory,$preference["widgetviewdirectory"]))) {
|
||||||
$this->get('session')->set('sessionviewdirectory',$sessionviewdirectory);
|
$toupdate=true;
|
||||||
|
$preference["widgetviewdirectory"][$directory]=$defaultview;
|
||||||
|
}
|
||||||
|
if($view&&$preference["widgetviewdirectory"][$directory]!=$view) {
|
||||||
|
$toupdate=true;
|
||||||
|
$preference["widgetviewdirectory"][$directory]=$view;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prérence trie
|
||||||
|
if(!array_key_exists("widgetsortdirectory",$preference)) {
|
||||||
|
$toupdate=true;
|
||||||
|
$preference["widgetsortdirectory"]=[];
|
||||||
|
}
|
||||||
|
if((!array_key_exists($directory,$preference["widgetsortdirectory"]))) {
|
||||||
|
$toupdate=true;
|
||||||
|
$preference["widgetsortdirectory"][$directory]="name";
|
||||||
|
}
|
||||||
|
if($sort&&$preference["widgetsortdirectory"][$directory]!=$sort) {
|
||||||
|
$toupdate=true;
|
||||||
|
$preference["widgetsortdirectory"][$directory]=$sort;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mise à jour des préferences
|
||||||
|
if($toupdate) {
|
||||||
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
$this->getUser()->setPreference($preference);
|
||||||
|
$em->persist($this->getUser());
|
||||||
|
$em->flush();
|
||||||
|
}
|
||||||
|
|
||||||
// Initialiser le service only
|
// Initialiser le service only
|
||||||
$onlyservice = $this->container->get('cadoles.portal.service.only');
|
$onlyservice = $this->container->get('cadoles.portal.service.only');
|
||||||
|
@ -84,7 +121,8 @@ class FrameController extends Controller
|
||||||
'subdirectory' => $subdirectory,
|
'subdirectory' => $subdirectory,
|
||||||
'files' => $files,
|
'files' => $files,
|
||||||
'canupdate' => $canupdate,
|
'canupdate' => $canupdate,
|
||||||
'view' => $sessionviewdirectory[$directory],
|
'view' => $preference["widgetviewdirectory"][$directory],
|
||||||
|
'sort' => $preference["widgetsortdirectory"][$directory],
|
||||||
'tasks' => $tasks,
|
'tasks' => $tasks,
|
||||||
'apponly' => $apponly
|
'apponly' => $apponly
|
||||||
]);
|
]);
|
||||||
|
|
Loading…
Reference in New Issue