| 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. |
| 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 |
} |
} |