| 1 |
<?php |
<?php |
| 2 |
// $Id: copyright.module,v 1.13.4.24 2007/06/18 06:28:24 robrechtj Exp $ |
// $Id: copyright.module,v 1.13.4.25 2007/10/05 15:47:40 robrechtj Exp $ |
| 3 |
|
|
| 4 |
/** Copyright (c) 2004 Matthew Schwartz <matt at mattschwartz dot net> |
/** Copyright (c) 2004 Matthew Schwartz <matt at mattschwartz dot net> |
| 5 |
Contributors: |
Contributors: |
| 483 |
/** |
/** |
| 484 |
* Implementation of hook_nodeapi(). |
* Implementation of hook_nodeapi(). |
| 485 |
*/ |
*/ |
| 486 |
function copyright_nodeapi(&$node, $op, $arg = 0) { |
function copyright_nodeapi(&$node, $op, $teaser = FALSE, $page = FALSE) { |
| 487 |
if (variable_get('copyright-enable_'. $node->type, 0)) { |
if (variable_get('copyright-enable_'. $node->type, 0)) { |
| 488 |
switch ($op) { |
switch ($op) { |
| 489 |
case 'view': |
case 'view': |
| 492 |
// $node->parent set at node load time by book.module |
// $node->parent set at node load time by book.module |
| 493 |
$node_license = copyright_parent_node($node->parent); |
$node_license = copyright_parent_node($node->parent); |
| 494 |
} |
} |
| 495 |
if ($node_license && $node_license->cpyid != variable_get('copyright-default', 1)) { |
|
| 496 |
// The node has a license other than the site's default |
$display_options = variable_get('copyright-display_'. $node->type, array('full', 'teaser')); |
| 497 |
|
if ($node_license && ($node_license->cpyid != variable_get('copyright-default', 1) || in_array('default', $display_options)) |
| 498 |
|
&& (($teaser && in_array('teaser', $display_options)) || (!$teaser && in_array('full', $display_options)))) { |
| 499 |
$license = copyright_get_license($node_license->cpyid); |
$license = copyright_get_license($node_license->cpyid); |
| 500 |
$node->content['copyright'] = array( |
$node->content['copyright'] = array( |
| 501 |
'#value' => theme('copyright_footer', copyright_notice($license, $node, $node_license)), |
'#value' => theme('copyright_footer', copyright_notice($license, $node, $node_license)), |
| 535 |
function copyright_form_alter($form_id, &$form) { |
function copyright_form_alter($form_id, &$form) { |
| 536 |
if ($form_id == 'node_type_form' && isset($form['identity']['type'])) { |
if ($form_id == 'node_type_form' && isset($form['identity']['type'])) { |
| 537 |
$type = $form['#node_type']->type; |
$type = $form['#node_type']->type; |
| 538 |
$form['workflow']['copyright-enable'] = array( |
$form['workflow']['copyright'] = array( |
| 539 |
|
'#type' => 'fieldset', |
| 540 |
|
'#title' => t('Copyright settings'), |
| 541 |
|
); |
| 542 |
|
$form['workflow']['copyright']['copyright-enable'] = array( |
| 543 |
'#type' => 'radios', |
'#type' => 'radios', |
| 544 |
'#title' => t('Allow copyright selection'), |
'#title' => t('Allow copyright selection'), |
| 545 |
'#default_value' => variable_get('copyright-enable_'. $type, 0), |
'#default_value' => variable_get('copyright-enable_'. $type, 0), |
| 546 |
'#options' => array(t('Disabled'), t('Enabled')), |
'#options' => array(t('Disabled'), t('Enabled')), |
| 547 |
'#description' => t('Enable the copyright selection for individual nodes of this content type.'), |
'#description' => t('Enable the copyright selection for individual nodes of this content type.'), |
| 548 |
); |
); |
| 549 |
|
$form['workflow']['copyright']['copyright-display'] = array( |
| 550 |
|
'#type' => 'checkboxes', |
| 551 |
|
'#title' => t('Copyright display options'), |
| 552 |
|
'#default_value' => variable_get('copyright-display_'. $type, array('full', 'teaser')), |
| 553 |
|
'#options' => array( |
| 554 |
|
'full' => t('Display notice on full node display'), |
| 555 |
|
'teaser' => t('Display notice on teaser display'), |
| 556 |
|
'default' => t('Display notice even when equal to default site notice'), |
| 557 |
|
), |
| 558 |
|
); |
| 559 |
} |
} |
| 560 |
|
|
| 561 |
if (isset($form['type'])) { |
if (isset($form['type'])) { |