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

Diff of /contributions/modules/iedestroyer/iedestroyer.module

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

revision 1.6.2.20, Thu Jun 26 21:47:36 2008 UTC revision 1.6.2.21, Sun Jul 27 18:40:53 2008 UTC
# Line 374  function _iedestroyer_should_display_pag Line 374  function _iedestroyer_should_display_pag
374      $page_match = FALSE;      $page_match = FALSE;
375    }    }
376    // Has the user got permission?    // Has the user got permission?
377    if (user_access('view iedestroyer') == FALSE) {    if (iedestroyer_view_access() == FALSE) {
378      $page_match = FALSE;      $page_match = FALSE;
379    }    }
380    // Check if this is IE.    // Check if this is IE.
# Line 432  function _iedestroyer_default_message($t Line 432  function _iedestroyer_default_message($t
432    
433  <a href="!url">Download !browser</a>. <strong>It\'s free.</strong>');  <a href="!url">Download !browser</a>. <strong>It\'s free.</strong>');
434    }    }
435    }
436    
437    /**
438     * Check if a user has access to view IE Destroyer
439     * User_access() cannot be used, because it
440     * 1) is not available in hook_init() with caching enabled and
441     * 2) cannot check whether user 1 has a certain permission, because this users always has all permissions
442     *
443     * @return boolean Whether the user has this permission or not
444     */
445    function iedestroyer_view_access() {
446      global $user;
447    
448      $placeholders = implode(',', array_fill(0, count($user->roles), '%d'));
449      $count = db_result(db_query("SELECT COUNT(p.perm) FROM {role} r INNER JOIN {permission} p ON p.rid = r.rid WHERE r.rid IN (". $placeholders .") AND p.perm LIKE '%view iedestroyer%'", array_keys($user->roles)));
450    
451      return (bool) $count;
452  }  }

Legend:
Removed from v.1.6.2.20  
changed lines
  Added in v.1.6.2.21

  ViewVC Help
Powered by ViewVC 1.1.2