Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix way to get vote number and get custom ranks #6

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions Controller/ListmembersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(){
Expand All @@ -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']);
Expand Down
6 changes: 5 additions & 1 deletion View/Listmembers/index.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
?>
</td>
Expand Down
18 changes: 12 additions & 6 deletions View/Listmembers/profil.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
?>
</td>
Expand All @@ -45,10 +49,12 @@
<td><?= $Lang->get('LISTMEMBERS__CREATE_DATE'); ?></td>
<td><b><?= $Lang->date($userFound['User']['created']); ?></b></td>
</tr>
<tr>
<td><?= $Lang->get('LISTMEMBERS__VOTE'); ?></td>
<td><b><?= $userFound['User']['vote']; ?> <?= $Lang->get('LISTMEMBERS__FS'); ?></b></td>
</tr>
<?php if ($EyPlugin->isInstalled('eywek.vote')) { ?>
<tr>
<td><?= $Lang->get('LISTMEMBERS__VOTE'); ?></td>
<td><b><?= $voteCount ?> <?= $Lang->get('LISTMEMBERS__FS'); ?></b></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
Expand Down Expand Up @@ -87,4 +93,4 @@
top: 10px;
font-size: 20px;
}
</style>
</style>