| 1 |
<?php |
<?php |
| 2 |
// vim:filetype=php expandtab tabstop=2 softtabstop=2 shiftwidth=2 autoindent smartindent |
// vim:filetype=php expandtab tabstop=2 softtabstop=2 shiftwidth=2 autoindent smartindent |
| 3 |
// $Id: tribune.module,v 1.159.2.5 2009/03/31 21:37:05 seeschloss Exp $ |
// $Id: tribune.module,v 1.159.2.6 2009/03/31 22:48:28 seeschloss Exp $ |
| 4 |
|
|
| 5 |
/** |
/** |
| 6 |
* Some variables |
* Some variables |
| 325 |
$contents = theme("tribune_page", $posts, $node, $tribune_id, $top_message, $node->tribune_settings['posts_order']); |
$contents = theme("tribune_page", $posts, $node, $tribune_id, $top_message, $node->tribune_settings['posts_order']); |
| 326 |
} |
} |
| 327 |
|
|
|
$posts = tribune_get_last_posts($node, 1); |
|
| 328 |
$contents = theme("tribune_page", $posts, $node, $tribune_id, $top_message, $node->tribune_settings['posts_order']); |
$contents = theme("tribune_page", $posts, $node, $tribune_id, $top_message, $node->tribune_settings['posts_order']); |
| 329 |
$node->content['body']['#value'] = $contents; |
$node->content['body']['#value'] = $contents; |
| 330 |
|
|
| 581 |
exit(); |
exit(); |
| 582 |
} |
} |
| 583 |
|
|
| 584 |
function tribune_build_block($node, $history_size) { |
function tribune_build_block($node, $history_size, $block_settings) { |
| 585 |
$block = array(); |
$block = array(); |
| 586 |
|
|
| 587 |
drupal_add_css(drupal_get_path('module', 'tribune') .'/css/tribune.block.css'); |
drupal_add_css(drupal_get_path('module', 'tribune') .'/css/tribune.block.css'); |
| 621 |
$posts = tribune_get_last_posts($node, $history_size); |
$posts = tribune_get_last_posts($node, $history_size); |
| 622 |
|
|
| 623 |
$block['subject'] = l($node->title, 'node/'. $node->nid); |
$block['subject'] = l($node->title, 'node/'. $node->nid); |
| 624 |
$block['content'] = theme("tribune_block", $posts, $node, $tribune_id); |
$block['content'] = theme("tribune_block", $posts, $node, $tribune_id, $block_settings); |
| 625 |
|
|
| 626 |
return $block; |
return $block; |
| 627 |
} |
} |
| 664 |
'#default_value' => $tribune_blocks[$delta]['history_size'], |
'#default_value' => $tribune_blocks[$delta]['history_size'], |
| 665 |
); |
); |
| 666 |
|
|
| 667 |
|
$form['read_only'] = array( |
| 668 |
|
'#type' => 'checkbox', |
| 669 |
|
'#title' => t('Read only'), |
| 670 |
|
'#description' => t('Make this block read-only (prevent posting from it)'), |
| 671 |
|
'#default_value' => $tribune_blocks[$delta]['read_only'], |
| 672 |
|
); |
| 673 |
|
|
| 674 |
return $form; |
return $form; |
| 675 |
break; |
break; |
| 676 |
case 'save': |
case 'save': |
| 679 |
$tribune_blocks[$delta]['nid'] = $tribune_id; |
$tribune_blocks[$delta]['nid'] = $tribune_id; |
| 680 |
$tribune_blocks[$delta]['config_display'] = $tribune_id ? $edit['tribune_id'] : ''; |
$tribune_blocks[$delta]['config_display'] = $tribune_id ? $edit['tribune_id'] : ''; |
| 681 |
$tribune_blocks[$delta]['history_size'] = $edit['history_size']; |
$tribune_blocks[$delta]['history_size'] = $edit['history_size']; |
| 682 |
|
$tribune_blocks[$delta]['read_only'] = $edit['read_only']; |
| 683 |
variable_set('tribune_blocks', $tribune_blocks); |
variable_set('tribune_blocks', $tribune_blocks); |
| 684 |
break; |
break; |
| 685 |
case 'view': |
case 'view': |
| 687 |
if ($tribune_blocks[$delta]['nid']) { |
if ($tribune_blocks[$delta]['nid']) { |
| 688 |
$node = node_load($tribune_blocks[$delta]['nid']); |
$node = node_load($tribune_blocks[$delta]['nid']); |
| 689 |
if (tribune_access("view", $node)) { |
if (tribune_access("view", $node)) { |
| 690 |
return tribune_build_block($node, $tribune_blocks[$delta]['history_size']); |
return tribune_build_block($node, $tribune_blocks[$delta]['history_size'], $tribune_blocks[$delta]); |
| 691 |
} |
} |
| 692 |
} |
} |
| 693 |
} |
} |
| 1350 |
} |
} |
| 1351 |
} |
} |
| 1352 |
|
|
| 1353 |
function theme_tribune_block($posts, $node, $tribune_id) { |
function theme_tribune_block($posts, $node, $tribune_id, $block_settings) { |
| 1354 |
if ($node->tribune_settings['posts_order'] == 0) { |
if ($node->tribune_settings['posts_order'] == 0) { |
| 1355 |
$posts = array_reverse($posts); |
$posts = array_reverse($posts); |
| 1356 |
} |
} |
| 1366 |
$contents .= "</ul>\n"; |
$contents .= "</ul>\n"; |
| 1367 |
|
|
| 1368 |
if ($node->tribune_settings['posts_order'] == 0) { |
if ($node->tribune_settings['posts_order'] == 0) { |
| 1369 |
return drupal_get_form('tribune_add_form_block', $node, $tribune_id) . $contents; |
return drupal_get_form('tribune_add_form_block', $node, $tribune_id, $block_settings) . $contents; |
| 1370 |
} else { |
} else { |
| 1371 |
return $contents . drupal_get_form('tribune_add_form_block', $node, $tribune_id); |
return $contents . drupal_get_form('tribune_add_form_block', $node, $tribune_id, $block_settings); |
| 1372 |
} |
} |
| 1373 |
} |
} |
| 1374 |
|
|
| 1829 |
* Generates the form for posting in the block tribune |
* Generates the form for posting in the block tribune |
| 1830 |
* @param block Whether the tribune is displayed in a block or not |
* @param block Whether the tribune is displayed in a block or not |
| 1831 |
*/ |
*/ |
| 1832 |
function tribune_add_form_block($form_values, $node, $tribune_id) { |
function tribune_add_form_block($form_values, $node, $tribune_id, $block_settings = array()) { |
| 1833 |
$form = array(); |
$form = array(); |
| 1834 |
|
|
| 1835 |
if (tribune_access("post", $node)) { |
if (!$block_settings['read_only'] and tribune_access("post", $node)) { |
| 1836 |
global $base_root; |
global $base_root; |
| 1837 |
|
|
| 1838 |
$form['#attributes'] = array("class" => "tribune-post-form"); |
$form['#attributes'] = array("class" => "tribune-post-form"); |