| 1 |
<?php /* $Id: premium.module,v 1.13 2008/08/03 04:05:25 vauxia Exp $ */ |
<?php /* $Id: premium.module,v 1.14 2008/08/03 04:28:04 vauxia Exp $ */ |
| 2 |
/** |
/** |
| 3 |
* @file Restrict access to the full body of premium content |
* @file Restrict access to the full body of premium content |
| 4 |
*/ |
*/ |
| 288 |
function _premium_access($node, $teaser) { |
function _premium_access($node, $teaser) { |
| 289 |
if (isset($node->premium_access)) return $node->premium_access; |
if (isset($node->premium_access)) return $node->premium_access; |
| 290 |
|
|
| 291 |
// Not viewing the body, or it's not premium, or user has privileges. |
// Access is granted or revoked explicitly. |
|
if ($teaser || !$node->premium || user_access('access premium content')) { |
|
|
return TRUE; |
|
|
} |
|
|
|
|
|
// Access is granted explicitly. |
|
| 292 |
foreach (module_implements('premium_access') as $name) { |
foreach (module_implements('premium_access') as $name) { |
| 293 |
$function = $name .'_premium_access'; |
$function = $name .'_premium_access'; |
| 294 |
if (is_bool($access = $function($user, $node))) { |
if (is_bool($access = $function($user, $node))) { |
| 296 |
} |
} |
| 297 |
} |
} |
| 298 |
|
|
| 299 |
|
// Not viewing the body, or it's not premium, or user has privileges. |
| 300 |
|
if ($teaser || !$node->premium || user_access('access premium content')) { |
| 301 |
|
return TRUE; |
| 302 |
|
} |
| 303 |
|
|
| 304 |
// Nobody said we could access the node. |
// Nobody said we could access the node. |
| 305 |
return FALSE; |
return FALSE; |
| 306 |
} |
} |