/[drupal]/contributions/modules/hof/hof.module
ViewVC logotype

Diff of /contributions/modules/hof/hof.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.14, Sun Dec 14 22:35:53 2008 UTC revision 1.15, Mon Dec 15 05:00:00 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  /*  /*
3   * $Id: hof.module,v 1.13 2008/12/12 03:44:17 syscrusher Exp $   * $Id: hof.module,v 1.14 2008/12/14 22:35:53 syscrusher Exp $
4   *   *
5   * Hall-Of-Fame is a module that reports summary statistics for a Drupal   * Hall-Of-Fame is a module that reports summary statistics for a Drupal
6   * web site, with an emphasis on reports that are of interest to visitors   * web site, with an emphasis on reports that are of interest to visitors
# Line 206  function hof_menu() { Line 206  function hof_menu() {
206    );    );
207    $sections = hof_get_sections();    $sections = hof_get_sections();
208    foreach ($sections as $section=>$title) {    foreach ($sections as $section=>$title) {
     if ($section == 'default' || $section == 'all' || $section == 'toc') {  
       $acc = user_access('access hof');  
     }  
     else {  
       $acc1 = user_access('access hof');  
       $acc2 = user_access('access hof '. strtolower(preg_replace('/\W+/', ' ', $title)));  
       $acc = $acc1 && $acc2;  
     }  
209      $weight = ($section == 'all') ? 10 : 0;      $weight = ($section == 'all') ? 10 : 0;
210      $items['hof/'. $section] = array(      $items['hof/'. $section] = array(
211        'title' => $title,        'title' => $title,
212        'page callback' => 'hof_page',        'page callback' => 'hof_page',
213        'type' => MENU_CALLBACK,        'type' => MENU_CALLBACK,
214        'access' => 'user_access',        'access callback' => 'hof_access',
215        'access arguments' => array($acc),        'access arguments' => array($section),
216        'weight' => $weight,        'weight' => $weight,
217      );      );
218    }    }
# Line 229  function hof_menu() { Line 221  function hof_menu() {
221      'description' => t('Control the display of the Hall of Fame'),      'description' => t('Control the display of the Hall of Fame'),
222      'page callback'    => 'drupal_get_form',      'page callback'    => 'drupal_get_form',
223      'page arguments' => array('hof_settings_form'),      'page arguments' => array('hof_settings_form'),
224      'access'   => 'user_access',      'access callback'   => 'user_access',
225      'access arguments' => array('administer hof'),      'access arguments' => array('administer hof'),
226      'type'     => MENU_NORMAL_ITEM,      'type'     => MENU_NORMAL_ITEM,
227      );      );
228    return $items;    return $items;
229  }  }
230    
231    function hof_access($section) {
232      $sections = hof_get_sections();
233      if ($section == 'default' || $section == 'all' || $section == 'toc') {
234        $acc = user_access('access hof');
235      }
236      else {
237        $title = $sections[$section];
238        $section_access_key = 'access hof '. strtolower(preg_replace('/\W+/', ' ', $title));
239        $acc1 = user_access('access hof');
240        $acc2 = user_access($section_access_key);
241        $acc = $acc1 && $acc2;
242      }
243      return $acc;
244    }
245    
246    
247  /**  /**
248   * Enumerates, as an associative array, the sections and their (translatable) titles   * Enumerates, as an associative array, the sections and their (translatable) titles
249   */   */
# Line 268  function hof_get_allowed_sections() { Line 276  function hof_get_allowed_sections() {
276    $enabled = variable_get('hof_enable_sections', $sections);    $enabled = variable_get('hof_enable_sections', $sections);
277    foreach ($sections as $section=>$title) {    foreach ($sections as $section=>$title) {
278      if ($section != 'toc' && $section != 'all' && $section != 'default') {      if ($section != 'toc' && $section != 'all' && $section != 'default') {
279    /*
280        $title = strtolower(preg_replace('/\W+/', ' ', $title));        $title = strtolower(preg_replace('/\W+/', ' ', $title));
281        $perm = 'access hof '. $title;        $perm = 'access hof '. $title;
282        if (! $enabled[$section]) {        if (! $enabled[$section]) {
# Line 276  function hof_get_allowed_sections() { Line 285  function hof_get_allowed_sections() {
285        if (! user_access($perm)) {        if (! user_access($perm)) {
286          unset($sections[$section]);          unset($sections[$section]);
287        }        }
288    */
289          if (! $enabled[$section] || ! hof_access($section)) {
290            unset($sections[$section]);
291          }
292      }      }
293    }    }
294    return $sections;    return $sections;

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.15

  ViewVC Help
Powered by ViewVC 1.1.2