Comment réaliser une sélection dans un affichage
Bonjour,
Je voudrais savoir car je ne comprends pas la façon de faire pour pouvoir afficher un listing de résultat à partir d'une base de données.
En fait j'ai une liste de donnée avec en dernière colonne 2 boutons : modifier, supprimer. Ces boutons ne doivent être visible que par l'utilisateur qui a insérer la ligne ou l'administrateur.
J'ai une base de donnée admin ou je stock si la personne est admin pour un module.
Dans mon controleur j'ai mis :
indexControlleur.php :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| public function listactuAction()
{
$this->view->submenu = array(
$this->view->link('index', 'index') => 'Accueil'
);
$this->renderScript('common/submenu.phtml', 'submenu');
$this->_helper->viewRenderer->setNoRender(false);
$select = $this->_actuTable->select();
$select->order('date DESC');
$listing = $this->_actuTable->fetchAll($select)->toArray();
$this->view->listing = $listing;
} |
Ce que je voudrais savoir c comment faire pour qu'à l'affichage de la vue, gérer les droits ?
Voilà ma vue :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| <table style="width: 100%">
<tr>
<td></td>
<th>Texte</th>
<th></th>
<th>Date</th>
<td style="border:none;padding:0;margin:0;width: 20px;"></td>
</tr>
<?php $indL = 1; ?>
<?php foreach ($this->listing as $actualite) : ?>
<?php $dateAff->set($actualite['date'], 'YYYY-MM-DD HH:mm:ss', 'fr_FR'); ?>
<tr>
<td style="text-align: center;width:20px;"><?php echo $indL; ?></td>
<td>
<?php
if($actualite['titre'] != "") echo "<b>".$actualite['titre'] . "</b><hr />";
echo $actualite['texte'];
?>
</td>
<td style="text-align:center;padding:0;margin:0;width: 20px">
<?php
if($actualite['image'] !== NULL) {
$ext = strtolower(substr(strrchr($actualite['image'],"."),1));
$nomfic = (isset($actualite['nomfic']) ? $actualite['nomfic'] : 'file_'.date("Ymd"));
?>
<a class="tooltipModifActu" href="../download.php?file=accueil/actualites/<?php echo $actualite['image']; ?>&nomfic=<?php echo $nomfic; ?>" rel="<?php echo $this->baseUrl(); ?>/accueil/actualites/<?php echo $actualite['image']; ?>"><img src="<?php echo $this->baseUrl(); ?>/ico/<?php echo $ext; ?>.png" width="18" /></a>
<?php
}
?>
</td>
<td nowrap="nowrap" style="width: 70px;text-align:center;"><?php echo $dateAff->toString('dd-MM-YYYY'); ?></td>
<td style="text-align:center;border:none;padding:0;margin:0;width: 20px;">
<a href="<?php echo $this->link('index', 'modifactu'); ?>/a/<?php echo $actualite['id']; ?>" class="tooltip" title="Editer"><img src="<?php echo $this->baseUrl(); ?>/icons/edit.gif" /></a>
<a href="<?php echo $this->link('index', 'delactu'); ?>/a/<?php echo $actualite['id']; ?>" class="tooltip" title="Supprimer"><img src="<?php echo $this->baseUrl(); ?>/images/bin.gif" /></a>
</td>
</tr>
<?php $indL++; ?>
<?php endforeach; ?>
</table> |
Merci