Le code ci-dessous, ajouté dans un bloc, permet d'afficher à l'administrateur du site si et combien de messages sont en attente d'approbation.
Ceci permet de savoir si de nouveaux commentaires ont été posté pendant son absence.
Sous Drupal 5 :
<?php // Bloc seulement visible pour les administrateurs global $user; if( $user->uid != 1 ) return; /** * Comment is awaiting approval. */ define('COMMENT_NOT_PUBLISHED', 1); // Recuperation du nombre de commentaires non publiés $result = pager_query('SELECT COUNT(c.nid) AS nbCom FROM {comments} c INNER JOIN {users} u ON u.uid = c.uid WHERE c.status = %d'. COMMENT_NOT_PUBLISHED); if ( $nbComment = db_fetch_object($result)){ if( $nbComment->nbCom > 0){ drupal_set_message(t('<span style="color: #FF8800;font-weight: bold;">%nbCom</span> comment(s) waiting for <a href="?q=admin/content/comment/list/approval">approve</a>', array('%nbCom'=>$nbComment->nbCom)),'warning'); } } ?>
Sous Drupal 6 :
<?php // Bloc seulement visible pour les administrateurs global $user; if( $user->uid != 1 ) return; /** * Comment is awaiting approval. */ define('COMMENT_NOT_PUBLISHED', 1); // Recuperation du nombre de commentaires non publiés $result = pager_query('SELECT COUNT(c.nid) AS nbCom FROM {comments} c INNER JOIN {users} u ON u.uid = c.uid WHERE c.status = %d'. COMMENT_NOT_PUBLISHED); if ( $nbComment = db_fetch_object($result)){ if( $nbComment->nbCom > 0){ drupal_set_message(t('<span style="color: #FF8800;font-weight: bold;">%nbCom</span> comment(s) waiting for <a href="?q=admin/content/comment/approval">approve</a>', array('%nbCom'=>$nbComment->nbCom)),'warning'); } } ?>
MaJ 21-07-2008 : Autant pour moi, une petite erreur faisait que le message ne s'affichait pas. C'est reglé !
Maj 18-02-2009 : Rajout du code pour Drupal 6
