Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. /**
  5. * Implémentation du hook_block().
  6. *
  7. * Génère un ou plusieurs blocs programmatiquement.
  8. */
  9. function modblock_block($op = 'list', $delta = 0, $edit = array()) {
  10.  
  11. switch ($op) {
  12.  
  13. case 'list': // Renvoie la liste de TOUS les blocs.
  14. $blocks[0] = array(
  15. 'info' => t('Welcome!'),
  16. );
  17. return $blocks;
  18.  
  19. case 'view': // Renvoie le contenu d'UN SEUL bloc
  20. // identifié par $delta.
  21. if ($delta == 0) {
  22.  
  23. if (user_access('access modblock')) {
  24. $content = t('Welcome! It <is %heure.', array('%heure' => date('H:i')));
  25. }
  26. else {
  27. $content = '';
  28. }
  29. $block = array(
  30. 'subject' => t('Welcome!'),
  31. 'content' => $content,
  32. );
  33. }
  34.  
  35. return $block;
  36. }
  37.  
  38. }
  39.  
  40.  
  41. /**
  42. * Implémentation du hook_perm().
  43. *
  44. * Déclare de nouvelles permissions visibles sur
  45. * Admin > Gestion des utilisateurs > Droits d'accès.
  46. */
  47. function modblock_perm() {
  48. return array('access modblock');
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement