From 99c6343dacb5afdcc347c6493eb494f08ca7a949 Mon Sep 17 00:00:00 2001 From: StanByes <73603926+StanByes@users.noreply.github.com> Date: Fri, 20 Aug 2021 22:32:09 +0200 Subject: [PATCH 1/3] Add rank custom support --- Controller/ListmembersController.php | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/Controller/ListmembersController.php b/Controller/ListmembersController.php index 71e20b9..90dc8a9 100644 --- a/Controller/ListmembersController.php +++ b/Controller/ListmembersController.php @@ -12,8 +12,15 @@ public function index(){ $this->loadModel('ListMembers.Perm'); $permGetMailEtat = $this->Perm->getListMembersByPerm('mail_perm', 'etat'); $users = $this->Users->find('all', ['order' => 'id ASC']); - $this->set(compact("users")); - $this->set(compact("permGetMailEtat")); + + //RÉCUPÉRATION DES RANKS CUSTOMS + $this->loadModel('Rank'); + $custom_ranks = $this->Rank->find('all'); + foreach ($custom_ranks as $key => $value) { + $available_ranks[$value['Rank']['rank_id']] = $value['Rank']['name']; + } + + $this->set(compact("users", "permGetMailEtat", "available_ranks")); } public function profil(){ @@ -26,9 +33,23 @@ public function profil(){ //ISOLEMENT DES INFORMATIONS DE L'UTILISATEUR PORTANT L'ID USER SORTIS EN PARAMETRE + REQUETE SQL $conditions = array("User.id" => array($id)); $userFound = $this->User->find('first', array('conditions' => $conditions)); + + //RÉCUPÉRATION DU NOMBRE DE VOTES DU MEMBRE + if ($this->EyPlugin->isInstalled('eywek.vote')) { + $this->loadModel("Vote.Vote"); + $voteCount = count($this->Vote->find('all', ['conditions' => ['user_id' => $userFound["User"]["id"]]])); + } + + //RÉCUPÉRATION DES RANKS CUSTOMS + $this->loadModel('Rank'); + $custom_ranks = $this->Rank->find('all'); + foreach ($custom_ranks as $key => $value) { + $available_ranks[$value['Rank']['rank_id']] = $value['Rank']['name']; + } + //SORTIE DE LA VARIABLE POUR LE VIEW - $this->set(compact("userFound")); + $this->set(compact("userFound", "voteCount", "available_ranks")); //CREATION DE LA VARIABLE TITLE POUR LE TITRE DE L'ONGLET $this->set('title_for_layout', $this->Lang->get('LISTMEMBERS__PROFILE').' '.$userFound['User']['pseudo']); From f8e6f15d4eef1186a784ea287c7616739e52aa57 Mon Sep 17 00:00:00 2001 From: StanByes <73603926+StanByes@users.noreply.github.com> Date: Fri, 20 Aug 2021 22:33:02 +0200 Subject: [PATCH 2/3] Add custom rank support --- View/Listmembers/index.ctp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/View/Listmembers/index.ctp b/View/Listmembers/index.ctp index 2a50e74..fa19699 100644 --- a/View/Listmembers/index.ctp +++ b/View/Listmembers/index.ctp @@ -42,7 +42,11 @@ }elseif($v['rank'] == 5){ echo $Lang->get('LISTMEMBERS__RANK_BANNED'); }else{ - echo $Lang->get('LISTMEMBERS__ERREUR'); + foreach ($available_ranks as $key => $value) { + if ($v['rank'] == $key) { + echo $value; + } + } } ?> From 86f26dbb362dc2e9106010352e5cc474f824c9f9 Mon Sep 17 00:00:00 2001 From: StanByes <73603926+StanByes@users.noreply.github.com> Date: Fri, 20 Aug 2021 22:33:50 +0200 Subject: [PATCH 3/3] Add custom rank support --- View/Listmembers/profil.ctp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/View/Listmembers/profil.ctp b/View/Listmembers/profil.ctp index 6ce2eaf..2633db3 100644 --- a/View/Listmembers/profil.ctp +++ b/View/Listmembers/profil.ctp @@ -36,7 +36,11 @@ }elseif($userFound['User']['rank'] == 5){ echo $Lang->get('LISTMEMBERS__RANK_BANNED'); }else{ - echo $Lang->get('LISTMEMBERS__ERREUR'); + foreach ($available_ranks as $key => $value) { + if ($userFound['User']['rank'] == $key) { + echo $value; + } + } } ?> @@ -45,10 +49,12 @@ get('LISTMEMBERS__CREATE_DATE'); ?> date($userFound['User']['created']); ?> - - get('LISTMEMBERS__VOTE'); ?> - get('LISTMEMBERS__FS'); ?> - + isInstalled('eywek.vote')) { ?> + + get('LISTMEMBERS__VOTE'); ?> + get('LISTMEMBERS__FS'); ?> + + @@ -87,4 +93,4 @@ top: 10px; font-size: 20px; } - \ No newline at end of file +