Initial code using Drupal 6.38
This commit is contained in:
commit
4824608a33
467 changed files with 90887 additions and 0 deletions
20
modules/comment/comment-folded.tpl.php
Normal file
20
modules/comment/comment-folded.tpl.php
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file comment-folded.tpl.php
|
||||
* Default theme implementation for folded comments.
|
||||
*
|
||||
* Available variables:
|
||||
* - $title: Linked title to full comment.
|
||||
* - $new: New comment marker.
|
||||
* - $author: Comment author. Can be link or plain text.
|
||||
* - $date: Date and time of posting.
|
||||
* - $comment: Full comment object.
|
||||
*
|
||||
* @see template_preprocess_comment_folded()
|
||||
* @see theme_comment_folded()
|
||||
*/
|
||||
?>
|
||||
<div class="comment-folded">
|
||||
<span class="subject"><?php print $title .' '. $new; ?></span><span class="credit"><?php print t('by') .' '. $author; ?></span>
|
||||
</div>
|
5
modules/comment/comment-rtl.css
Normal file
5
modules/comment/comment-rtl.css
Normal file
|
@ -0,0 +1,5 @@
|
|||
|
||||
.indented {
|
||||
margin-left: 0;
|
||||
margin-right: 25px;
|
||||
}
|
34
modules/comment/comment-wrapper.tpl.php
Normal file
34
modules/comment/comment-wrapper.tpl.php
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file comment-wrapper.tpl.php
|
||||
* Default theme implementation to wrap comments.
|
||||
*
|
||||
* Available variables:
|
||||
* - $content: All comments for a given page. Also contains sorting controls
|
||||
* and comment forms if the site is configured for it.
|
||||
*
|
||||
* The following variables are provided for contextual information.
|
||||
* - $node: Node object the comments are attached to.
|
||||
* The constants below the variables show the possible values and should be
|
||||
* used for comparison.
|
||||
* - $display_mode
|
||||
* - COMMENT_MODE_FLAT_COLLAPSED
|
||||
* - COMMENT_MODE_FLAT_EXPANDED
|
||||
* - COMMENT_MODE_THREADED_COLLAPSED
|
||||
* - COMMENT_MODE_THREADED_EXPANDED
|
||||
* - $display_order
|
||||
* - COMMENT_ORDER_NEWEST_FIRST
|
||||
* - COMMENT_ORDER_OLDEST_FIRST
|
||||
* - $comment_controls_state
|
||||
* - COMMENT_CONTROLS_ABOVE
|
||||
* - COMMENT_CONTROLS_BELOW
|
||||
* - COMMENT_CONTROLS_ABOVE_BELOW
|
||||
* - COMMENT_CONTROLS_HIDDEN
|
||||
*
|
||||
* @see template_preprocess_comment_wrapper()
|
||||
*/
|
||||
?>
|
||||
<div id="comments">
|
||||
<?php print $content; ?>
|
||||
</div>
|
294
modules/comment/comment.admin.inc
Normal file
294
modules/comment/comment.admin.inc
Normal file
|
@ -0,0 +1,294 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Admin page callbacks for the comment module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Menu callback; present an administrative comment listing.
|
||||
*/
|
||||
function comment_admin($type = 'new') {
|
||||
$edit = $_POST;
|
||||
|
||||
if (isset($edit['operation']) && ($edit['operation'] == 'delete') && isset($edit['comments']) && $edit['comments']) {
|
||||
return drupal_get_form('comment_multiple_delete_confirm');
|
||||
}
|
||||
else {
|
||||
return drupal_get_form('comment_admin_overview', $type, arg(4));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Form builder; Builds the comment overview form for the admin.
|
||||
*
|
||||
* @param $type
|
||||
* Not used.
|
||||
* @param $arg
|
||||
* Current path's fourth component deciding the form type (Published comments/Approval queue)
|
||||
* @return
|
||||
* The form structure.
|
||||
* @ingroup forms
|
||||
* @see comment_admin_overview_validate()
|
||||
* @see comment_admin_overview_submit()
|
||||
* @see theme_comment_admin_overview()
|
||||
*/
|
||||
function comment_admin_overview($type = 'new', $arg) {
|
||||
// build an 'Update options' form
|
||||
$form['options'] = array(
|
||||
'#type' => 'fieldset', '#title' => t('Update options'),
|
||||
'#prefix' => '<div class="container-inline">', '#suffix' => '</div>'
|
||||
);
|
||||
$options = array();
|
||||
foreach (comment_operations($arg == 'approval' ? 'publish' : 'unpublish') as $key => $value) {
|
||||
$options[$key] = $value[0];
|
||||
}
|
||||
$form['options']['operation'] = array('#type' => 'select', '#options' => $options, '#default_value' => 'publish');
|
||||
$form['options']['submit'] = array('#type' => 'submit', '#value' => t('Update'));
|
||||
|
||||
// load the comments that we want to display
|
||||
$status = ($arg == 'approval') ? COMMENT_NOT_PUBLISHED : COMMENT_PUBLISHED;
|
||||
$form['header'] = array('#type' => 'value', '#value' => array(
|
||||
theme('table_select_header_cell'),
|
||||
array('data' => t('Subject'), 'field' => 'subject'),
|
||||
array('data' => t('Author'), 'field' => 'name'),
|
||||
array('data' => t('Posted in'), 'field' => 'node_title'),
|
||||
array('data' => t('Time'), 'field' => 'timestamp', 'sort' => 'desc'),
|
||||
array('data' => t('Operations'))
|
||||
));
|
||||
$result = pager_query('SELECT c.subject, c.nid, c.cid, c.comment, c.timestamp, c.status, c.name, c.homepage, u.name AS registered_name, u.uid, n.title as node_title FROM {comments} c INNER JOIN {users} u ON u.uid = c.uid INNER JOIN {node} n ON n.nid = c.nid WHERE c.status = %d'. tablesort_sql($form['header']['#value']), 50, 0, NULL, $status);
|
||||
|
||||
// build a table listing the appropriate comments
|
||||
$destination = drupal_get_destination();
|
||||
while ($comment = db_fetch_object($result)) {
|
||||
$comments[$comment->cid] = '';
|
||||
$comment->name = $comment->uid ? $comment->registered_name : $comment->name;
|
||||
$form['subject'][$comment->cid] = array('#value' => l($comment->subject, 'node/'. $comment->nid, array('attributes' => array('title' => truncate_utf8($comment->comment, 128)), 'fragment' => 'comment-'. $comment->cid)));
|
||||
$form['username'][$comment->cid] = array('#value' => theme('username', $comment));
|
||||
$form['node_title'][$comment->cid] = array('#value' => l($comment->node_title, 'node/'. $comment->nid));
|
||||
$form['timestamp'][$comment->cid] = array('#value' => format_date($comment->timestamp, 'small'));
|
||||
$form['operations'][$comment->cid] = array('#value' => l(t('edit'), 'comment/edit/'. $comment->cid, array('query' => $destination)));
|
||||
}
|
||||
$form['comments'] = array('#type' => 'checkboxes', '#options' => isset($comments) ? $comments: array());
|
||||
$form['pager'] = array('#value' => theme('pager', NULL, 50, 0));
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate comment_admin_overview form submissions.
|
||||
*
|
||||
* We can't execute any 'Update options' if no comments were selected.
|
||||
*/
|
||||
function comment_admin_overview_validate($form, &$form_state) {
|
||||
$form_state['values']['comments'] = array_diff($form_state['values']['comments'], array(0));
|
||||
if (count($form_state['values']['comments']) == 0) {
|
||||
form_set_error('', t('Please select one or more comments to perform the update on.'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process comment_admin_overview form submissions.
|
||||
*
|
||||
* Execute the chosen 'Update option' on the selected comments, such as
|
||||
* publishing, unpublishing or deleting.
|
||||
*/
|
||||
function comment_admin_overview_submit($form, &$form_state) {
|
||||
$operations = comment_operations();
|
||||
if (!empty($operations[$form_state['values']['operation']][1])) {
|
||||
// extract the appropriate database query operation
|
||||
$query = $operations[$form_state['values']['operation']][1];
|
||||
foreach ($form_state['values']['comments'] as $cid => $value) {
|
||||
if ($value) {
|
||||
// perform the update action, then refresh node statistics
|
||||
db_query($query, $cid);
|
||||
$comment = _comment_load($cid);
|
||||
_comment_update_node_statistics($comment->nid);
|
||||
// Allow modules to respond to the updating of a comment.
|
||||
comment_invoke_comment($comment, $form_state['values']['operation']);
|
||||
// Add an entry to the watchdog log.
|
||||
watchdog('content', 'Comment: updated %subject.', array('%subject' => $comment->subject), WATCHDOG_NOTICE, l(t('view'), 'node/'. $comment->nid, array('fragment' => 'comment-'. $comment->cid)));
|
||||
}
|
||||
}
|
||||
cache_clear_all();
|
||||
drupal_set_message(t('The update has been performed.'));
|
||||
$form_state['redirect'] = 'admin/content/comment';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Theme the comment admin form.
|
||||
*
|
||||
* @param $form
|
||||
* An associative array containing the structure of the form.
|
||||
* @ingroup themeable
|
||||
*/
|
||||
function theme_comment_admin_overview($form) {
|
||||
$output = drupal_render($form['options']);
|
||||
if (isset($form['subject']) && is_array($form['subject'])) {
|
||||
foreach (element_children($form['subject']) as $key) {
|
||||
$row = array();
|
||||
$row[] = drupal_render($form['comments'][$key]);
|
||||
$row[] = drupal_render($form['subject'][$key]);
|
||||
$row[] = drupal_render($form['username'][$key]);
|
||||
$row[] = drupal_render($form['node_title'][$key]);
|
||||
$row[] = drupal_render($form['timestamp'][$key]);
|
||||
$row[] = drupal_render($form['operations'][$key]);
|
||||
$rows[] = $row;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$rows[] = array(array('data' => t('No comments available.'), 'colspan' => '6'));
|
||||
}
|
||||
|
||||
$output .= theme('table', $form['header']['#value'], $rows);
|
||||
if ($form['pager']['#value']) {
|
||||
$output .= drupal_render($form['pager']);
|
||||
}
|
||||
|
||||
$output .= drupal_render($form);
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* List the selected comments and verify that the admin really wants to delete
|
||||
* them.
|
||||
*
|
||||
* @param $form_state
|
||||
* An associative array containing the current state of the form.
|
||||
* @return
|
||||
* TRUE if the comments should be deleted, FALSE otherwise.
|
||||
* @ingroup forms
|
||||
* @see comment_multiple_delete_confirm_submit()
|
||||
*/
|
||||
function comment_multiple_delete_confirm(&$form_state) {
|
||||
$edit = $form_state['post'];
|
||||
|
||||
$form['comments'] = array('#prefix' => '<ul>', '#suffix' => '</ul>', '#tree' => TRUE);
|
||||
// array_filter() returns only elements with actual values
|
||||
$comment_counter = 0;
|
||||
foreach (array_filter($edit['comments']) as $cid => $value) {
|
||||
$comment = _comment_load($cid);
|
||||
if (is_object($comment) && is_numeric($comment->cid)) {
|
||||
$subject = db_result(db_query('SELECT subject FROM {comments} WHERE cid = %d', $cid));
|
||||
$form['comments'][$cid] = array('#type' => 'hidden', '#value' => $cid, '#prefix' => '<li>', '#suffix' => check_plain($subject) .'</li>');
|
||||
$comment_counter++;
|
||||
}
|
||||
}
|
||||
$form['operation'] = array('#type' => 'hidden', '#value' => 'delete');
|
||||
|
||||
if (!$comment_counter) {
|
||||
drupal_set_message(t('There do not appear to be any comments to delete or your selected comment was deleted by another administrator.'));
|
||||
drupal_goto('admin/content/comment');
|
||||
}
|
||||
else {
|
||||
return confirm_form($form,
|
||||
t('Are you sure you want to delete these comments and all their children?'),
|
||||
'admin/content/comment', t('This action cannot be undone.'),
|
||||
t('Delete comments'), t('Cancel'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process comment_multiple_delete_confirm form submissions.
|
||||
*
|
||||
* Perform the actual comment deletion.
|
||||
*/
|
||||
function comment_multiple_delete_confirm_submit($form, &$form_state) {
|
||||
if ($form_state['values']['confirm']) {
|
||||
foreach ($form_state['values']['comments'] as $cid => $value) {
|
||||
$comment = _comment_load($cid);
|
||||
_comment_delete_thread($comment);
|
||||
_comment_update_node_statistics($comment->nid);
|
||||
}
|
||||
cache_clear_all();
|
||||
drupal_set_message(t('The comments have been deleted.'));
|
||||
}
|
||||
$form_state['redirect'] = 'admin/content/comment';
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu callback; delete a comment.
|
||||
*
|
||||
* @param $cid
|
||||
* The comment do be deleted.
|
||||
*/
|
||||
function comment_delete($cid = NULL) {
|
||||
$comment = db_fetch_object(db_query('SELECT c.*, u.name AS registered_name, u.uid FROM {comments} c INNER JOIN {users} u ON u.uid = c.uid WHERE c.cid = %d', $cid));
|
||||
$comment->name = $comment->uid ? $comment->registered_name : $comment->name;
|
||||
|
||||
$output = '';
|
||||
|
||||
if (is_object($comment) && is_numeric($comment->cid)) {
|
||||
$output = drupal_get_form('comment_confirm_delete', $comment);
|
||||
}
|
||||
else {
|
||||
drupal_set_message(t('The comment no longer exists.'));
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Form builder; Builds the confirmation form for deleting a single comment.
|
||||
*
|
||||
* @ingroup forms
|
||||
* @see comment_confirm_delete_submit()
|
||||
*/
|
||||
function comment_confirm_delete(&$form_state, $comment) {
|
||||
$form = array();
|
||||
$form['#comment'] = $comment;
|
||||
return confirm_form(
|
||||
$form,
|
||||
t('Are you sure you want to delete the comment %title?', array('%title' => $comment->subject)),
|
||||
'node/'. $comment->nid,
|
||||
t('Any replies to this comment will be lost. This action cannot be undone.'),
|
||||
t('Delete'),
|
||||
t('Cancel'),
|
||||
'comment_confirm_delete');
|
||||
}
|
||||
|
||||
/**
|
||||
* Process comment_confirm_delete form submissions.
|
||||
*/
|
||||
function comment_confirm_delete_submit($form, &$form_state) {
|
||||
drupal_set_message(t('The comment and all its replies have been deleted.'));
|
||||
|
||||
$comment = $form['#comment'];
|
||||
|
||||
// Delete comment and its replies.
|
||||
_comment_delete_thread($comment);
|
||||
|
||||
_comment_update_node_statistics($comment->nid);
|
||||
|
||||
// Clear the cache so an anonymous user sees that his comment was deleted.
|
||||
cache_clear_all();
|
||||
|
||||
$form_state['redirect'] = "node/$comment->nid";
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform the actual deletion of a comment and all its replies.
|
||||
*
|
||||
* @param $comment
|
||||
* An associative array describing the comment to be deleted.
|
||||
*/
|
||||
function _comment_delete_thread($comment) {
|
||||
if (!is_object($comment) || !is_numeric($comment->cid)) {
|
||||
watchdog('content', 'Cannot delete non-existent comment.', array(), WATCHDOG_WARNING);
|
||||
return;
|
||||
}
|
||||
|
||||
// Delete the comment:
|
||||
db_query('DELETE FROM {comments} WHERE cid = %d', $comment->cid);
|
||||
watchdog('content', 'Comment: deleted %subject.', array('%subject' => $comment->subject));
|
||||
|
||||
comment_invoke_comment($comment, 'delete');
|
||||
|
||||
// Delete the comment's replies
|
||||
$result = db_query('SELECT c.*, u.name AS registered_name, u.uid FROM {comments} c INNER JOIN {users} u ON u.uid = c.uid WHERE pid = %d', $comment->cid);
|
||||
while ($comment = db_fetch_object($result)) {
|
||||
$comment->name = $comment->uid ? $comment->registered_name : $comment->name;
|
||||
_comment_delete_thread($comment);
|
||||
}
|
||||
}
|
10
modules/comment/comment.css
Normal file
10
modules/comment/comment.css
Normal file
|
@ -0,0 +1,10 @@
|
|||
|
||||
.indented {
|
||||
margin-left: 25px; /* LTR */
|
||||
}
|
||||
.comment-unpublished {
|
||||
background-color: #fff4f4;
|
||||
}
|
||||
.preview .comment {
|
||||
background-color: #ffffea;
|
||||
}
|
11
modules/comment/comment.info
Normal file
11
modules/comment/comment.info
Normal file
|
@ -0,0 +1,11 @@
|
|||
name = Comment
|
||||
description = Allows users to comment on and discuss published content.
|
||||
package = Core - optional
|
||||
version = VERSION
|
||||
core = 6.x
|
||||
|
||||
; Information added by Drupal.org packaging script on 2016-02-24
|
||||
version = "6.38"
|
||||
project = "drupal"
|
||||
datestamp = "1456343372"
|
||||
|
249
modules/comment/comment.install
Normal file
249
modules/comment/comment.install
Normal file
|
@ -0,0 +1,249 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Implementation of hook_enable().
|
||||
*/
|
||||
function comment_enable() {
|
||||
// Insert records into the node_comment_statistics for nodes that are missing.
|
||||
db_query("INSERT INTO {node_comment_statistics} (nid, last_comment_timestamp, last_comment_name, last_comment_uid, comment_count) SELECT n.nid, n.changed, NULL, n.uid, 0 FROM {node} n LEFT JOIN {node_comment_statistics} c ON n.nid = c.nid WHERE c.comment_count IS NULL");
|
||||
}
|
||||
|
||||
/**
|
||||
* Changed node_comment_statistics to use node->changed to avoid future timestamps.
|
||||
*/
|
||||
function comment_update_1() {
|
||||
// Change any future last comment timestamps to now.
|
||||
db_query('UPDATE {node_comment_statistics} SET last_comment_timestamp = %d WHERE last_comment_timestamp > %d', time(), time());
|
||||
|
||||
// Unstuck node indexing timestamp if needed.
|
||||
if (($last = variable_get('node_cron_last', FALSE)) !== FALSE) {
|
||||
variable_set('node_cron_last', min(time(), $last));
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
function comment_update_6001() {
|
||||
$ret[] = update_sql("ALTER TABLE {comments} DROP score");
|
||||
$ret[] = update_sql("ALTER TABLE {comments} DROP users");
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Changed comment settings from global to per-node -- copy global
|
||||
* settings to all node types.
|
||||
*/
|
||||
function comment_update_6002() {
|
||||
// Comment module might not be enabled when this is run, but we need the
|
||||
// constants defined by the module for this update.
|
||||
drupal_load('module', 'comment');
|
||||
$settings = array(
|
||||
'comment_default_mode' => COMMENT_MODE_THREADED_EXPANDED,
|
||||
'comment_default_order' => COMMENT_ORDER_NEWEST_FIRST,
|
||||
'comment_default_per_page' => 50,
|
||||
'comment_controls' => COMMENT_CONTROLS_HIDDEN,
|
||||
'comment_anonymous' => COMMENT_ANONYMOUS_MAYNOT_CONTACT,
|
||||
'comment_subject_field' => 1,
|
||||
'comment_preview' => COMMENT_PREVIEW_REQUIRED,
|
||||
'comment_form_location' => COMMENT_FORM_SEPARATE_PAGE,
|
||||
);
|
||||
$types = node_get_types();
|
||||
foreach ($settings as $setting => $default) {
|
||||
$value = variable_get($setting, $default);
|
||||
foreach ($types as $type => $object) {
|
||||
variable_set($setting .'_'. $type, $value);
|
||||
}
|
||||
variable_del($setting);
|
||||
}
|
||||
return array(array('success' => TRUE, 'query' => 'Global comment settings copied to all node types.'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add index to parent ID field.
|
||||
*/
|
||||
function comment_update_6003() {
|
||||
$ret = array();
|
||||
db_add_index($ret, 'comments', 'pid', array('pid'));
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @addtogroup updates-6.x-extra
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Add index to to node_comment_statistics on comment_count
|
||||
*/
|
||||
function comment_update_6004() {
|
||||
$ret = array();
|
||||
db_add_index($ret, 'node_comment_statistics', 'comment_count', array('comment_count'));
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add indices to uid fields.
|
||||
*/
|
||||
function comment_update_6005() {
|
||||
$ret = array();
|
||||
db_add_index($ret, 'comments', 'comment_uid', array('uid'));
|
||||
db_add_index($ret, 'node_comment_statistics', 'last_comment_uid', array('last_comment_uid'));
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @} End of "addtogroup updates-6.x-extra".
|
||||
* The next series of updates should start at 7000.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of hook_schema().
|
||||
*/
|
||||
function comment_schema() {
|
||||
$schema['comments'] = array(
|
||||
'description' => 'Stores comments and associated data.',
|
||||
'fields' => array(
|
||||
'cid' => array(
|
||||
'type' => 'serial',
|
||||
'not null' => TRUE,
|
||||
'description' => 'Primary Key: Unique comment ID.',
|
||||
),
|
||||
'pid' => array(
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
'description' => 'The {comments}.cid to which this comment is a reply. If set to 0, this comment is not a reply to an existing comment.',
|
||||
),
|
||||
'nid' => array(
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
'description' => 'The {node}.nid to which this comment is a reply.',
|
||||
),
|
||||
'uid' => array(
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
'description' => 'The {users}.uid who authored the comment. If set to 0, this comment was created by an anonymous user.',
|
||||
),
|
||||
'subject' => array(
|
||||
'type' => 'varchar',
|
||||
'length' => 64,
|
||||
'not null' => TRUE,
|
||||
'default' => '',
|
||||
'description' => 'The comment title.',
|
||||
),
|
||||
'comment' => array(
|
||||
'type' => 'text',
|
||||
'not null' => TRUE,
|
||||
'size' => 'big',
|
||||
'description' => 'The comment body.',
|
||||
),
|
||||
'hostname' => array(
|
||||
'type' => 'varchar',
|
||||
'length' => 128,
|
||||
'not null' => TRUE,
|
||||
'default' => '',
|
||||
'description' => "The author's host name.",
|
||||
),
|
||||
'timestamp' => array(
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
'description' => 'The time that the comment was created, or last edited by its author, as a Unix timestamp.',
|
||||
),
|
||||
'status' => array(
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
'size' => 'tiny',
|
||||
'description' => 'The published status of a comment. (0 = Published, 1 = Not Published)',
|
||||
),
|
||||
'format' => array(
|
||||
'type' => 'int',
|
||||
'size' => 'small',
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
'description' => 'The {filter_formats}.format of the comment body.',
|
||||
),
|
||||
'thread' => array(
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
'description' => "The vancode representation of the comment's place in a thread.",
|
||||
),
|
||||
'name' => array(
|
||||
'type' => 'varchar',
|
||||
'length' => 60,
|
||||
'not null' => FALSE,
|
||||
'description' => "The comment author's name. Uses {users}.name if the user is logged in, otherwise uses the value typed into the comment form.",
|
||||
),
|
||||
'mail' => array(
|
||||
'type' => 'varchar',
|
||||
'length' => 64,
|
||||
'not null' => FALSE,
|
||||
'description' => "The comment author's e-mail address from the comment form, if user is anonymous, and the 'Anonymous users may/must leave their contact information' setting is turned on.",
|
||||
),
|
||||
'homepage' => array(
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => FALSE,
|
||||
'description' => "The comment author's home page address from the comment form, if user is anonymous, and the 'Anonymous users may/must leave their contact information' setting is turned on.",
|
||||
)
|
||||
),
|
||||
'indexes' => array(
|
||||
'pid' => array('pid'),
|
||||
'nid' => array('nid'),
|
||||
'comment_uid' => array('uid'),
|
||||
'status' => array('status'), // This index is probably unused
|
||||
),
|
||||
'primary key' => array('cid'),
|
||||
);
|
||||
|
||||
$schema['node_comment_statistics'] = array(
|
||||
'description' => 'Maintains statistics of node and comments posts to show "new" and "updated" flags.',
|
||||
'fields' => array(
|
||||
'nid' => array(
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
'description' => 'The {node}.nid for which the statistics are compiled.',
|
||||
),
|
||||
'last_comment_timestamp' => array(
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
'description' => 'The Unix timestamp of the last comment that was posted within this node, from {comments}.timestamp.',
|
||||
),
|
||||
'last_comment_name' => array(
|
||||
'type' => 'varchar',
|
||||
'length' => 60,
|
||||
'not null' => FALSE,
|
||||
'description' => 'The name of the latest author to post a comment on this node, from {comments}.name.',
|
||||
),
|
||||
'last_comment_uid' => array(
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
'description' => 'The user ID of the latest author to post a comment on this node, from {comments}.uid.',
|
||||
),
|
||||
'comment_count' => array(
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
'description' => 'The total number of comments on this node.',
|
||||
),
|
||||
),
|
||||
'primary key' => array('nid'),
|
||||
'indexes' => array(
|
||||
'node_comment_timestamp' => array('last_comment_timestamp'),
|
||||
'comment_count' => array('comment_count'),
|
||||
'last_comment_uid' => array('last_comment_uid'),
|
||||
),
|
||||
);
|
||||
|
||||
return $schema;
|
||||
}
|
34
modules/comment/comment.js
Normal file
34
modules/comment/comment.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
|
||||
Drupal.behaviors.comment = function (context) {
|
||||
var parts = new Array("name", "homepage", "mail");
|
||||
var cookie = '';
|
||||
for (i=0;i<3;i++) {
|
||||
cookie = Drupal.comment.getCookie('comment_info_' + parts[i]);
|
||||
if (cookie != '') {
|
||||
$("#comment-form input[name=" + parts[i] + "]:not(.comment-processed)", context)
|
||||
.val(cookie)
|
||||
.addClass('comment-processed');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.comment = {};
|
||||
|
||||
Drupal.comment.getCookie = function(name) {
|
||||
var search = name + '=';
|
||||
var returnValue = '';
|
||||
|
||||
if (document.cookie.length > 0) {
|
||||
offset = document.cookie.indexOf(search);
|
||||
if (offset != -1) {
|
||||
offset += search.length;
|
||||
var end = document.cookie.indexOf(';', offset);
|
||||
if (end == -1) {
|
||||
end = document.cookie.length;
|
||||
}
|
||||
returnValue = decodeURIComponent(document.cookie.substring(offset, end).replace(/\+/g, '%20'));
|
||||
}
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
};
|
2155
modules/comment/comment.module
Normal file
2155
modules/comment/comment.module
Normal file
File diff suppressed because it is too large
Load diff
115
modules/comment/comment.pages.inc
Normal file
115
modules/comment/comment.pages.inc
Normal file
|
@ -0,0 +1,115 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* User page callbacks for the comment module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Form builder; generate a comment editing form.
|
||||
*
|
||||
* @param $cid
|
||||
* ID of the comment to be edited.
|
||||
* @ingroup forms
|
||||
*/
|
||||
function comment_edit($cid) {
|
||||
global $user;
|
||||
|
||||
$comment = db_fetch_object(db_query('SELECT c.*, u.uid, u.name AS registered_name, u.data FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d', $cid));
|
||||
$comment = drupal_unpack($comment);
|
||||
$comment->name = $comment->uid ? $comment->registered_name : $comment->name;
|
||||
if (comment_access('edit', $comment)) {
|
||||
return comment_form_box((array)$comment);
|
||||
}
|
||||
else {
|
||||
drupal_access_denied();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is responsible for generating a comment reply form.
|
||||
* There are several cases that have to be handled, including:
|
||||
* - replies to comments
|
||||
* - replies to nodes
|
||||
* - attempts to reply to nodes that can no longer accept comments
|
||||
* - respecting access permissions ('access comments', 'post comments', etc.)
|
||||
*
|
||||
* The node or comment that is being replied to must appear above the comment
|
||||
* form to provide the user context while authoring the comment.
|
||||
*
|
||||
* @param $node
|
||||
* Every comment belongs to a node. This is that node.
|
||||
*
|
||||
* @param $pid
|
||||
* Some comments are replies to other comments. In those cases, $pid is the parent
|
||||
* comment's cid.
|
||||
*
|
||||
* @return
|
||||
* The rendered parent node or comment plus the new comment form.
|
||||
*/
|
||||
function comment_reply($node, $pid = NULL) {
|
||||
// Set the breadcrumb trail.
|
||||
drupal_set_breadcrumb(array(l(t('Home'), NULL), l($node->title, 'node/'. $node->nid)));
|
||||
$op = isset($_POST['op']) ? $_POST['op'] : '';
|
||||
|
||||
$output = '';
|
||||
|
||||
if (user_access('access comments')) {
|
||||
// The user is previewing a comment prior to submitting it.
|
||||
if ($op == t('Preview')) {
|
||||
if (user_access('post comments')) {
|
||||
$output .= comment_form_box(array('pid' => $pid, 'nid' => $node->nid), NULL);
|
||||
}
|
||||
else {
|
||||
drupal_set_message(t('You are not authorized to post comments.'), 'error');
|
||||
drupal_goto("node/$node->nid");
|
||||
}
|
||||
}
|
||||
else {
|
||||
// $pid indicates that this is a reply to a comment.
|
||||
if ($pid) {
|
||||
// load the comment whose cid = $pid
|
||||
if ($comment = db_fetch_object(db_query('SELECT c.*, u.uid, u.name AS registered_name, u.signature, u.signature_format, u.picture, u.data FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d AND c.status = %d', $pid, COMMENT_PUBLISHED))) {
|
||||
// If that comment exists, make sure that the current comment and the parent comment both
|
||||
// belong to the same parent node.
|
||||
if ($comment->nid != $node->nid) {
|
||||
// Attempting to reply to a comment not belonging to the current nid.
|
||||
drupal_set_message(t('The comment you are replying to does not exist.'), 'error');
|
||||
drupal_goto("node/$node->nid");
|
||||
}
|
||||
// Display the parent comment
|
||||
$comment = drupal_unpack($comment);
|
||||
$comment->name = $comment->uid ? $comment->registered_name : $comment->name;
|
||||
$output .= theme('comment_view', $comment, $node);
|
||||
}
|
||||
else {
|
||||
drupal_set_message(t('The comment you are replying to does not exist.'), 'error');
|
||||
drupal_goto("node/$node->nid");
|
||||
}
|
||||
}
|
||||
// This is the case where the comment is in response to a node. Display the node.
|
||||
else if (user_access('access content')) {
|
||||
$output .= node_view($node);
|
||||
}
|
||||
|
||||
// Should we show the reply box?
|
||||
if (node_comment_mode($node->nid) != COMMENT_NODE_READ_WRITE) {
|
||||
drupal_set_message(t("This discussion is closed: you can't post new comments."), 'error');
|
||||
drupal_goto("node/$node->nid");
|
||||
}
|
||||
else if (user_access('post comments')) {
|
||||
$output .= comment_form_box(array('pid' => $pid, 'nid' => $node->nid), t('Reply'));
|
||||
}
|
||||
else {
|
||||
drupal_set_message(t('You are not authorized to post comments.'), 'error');
|
||||
drupal_goto("node/$node->nid");
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
drupal_set_message(t('You are not authorized to view comments.'), 'error');
|
||||
drupal_goto("node/$node->nid");
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
51
modules/comment/comment.tpl.php
Normal file
51
modules/comment/comment.tpl.php
Normal file
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file comment.tpl.php
|
||||
* Default theme implementation for comments.
|
||||
*
|
||||
* Available variables:
|
||||
* - $author: Comment author. Can be link or plain text.
|
||||
* - $content: Body of the post.
|
||||
* - $date: Date and time of posting.
|
||||
* - $links: Various operational links.
|
||||
* - $new: New comment marker.
|
||||
* - $picture: Authors picture.
|
||||
* - $signature: Authors signature.
|
||||
* - $status: Comment status. Possible values are:
|
||||
* comment-unpublished, comment-published or comment-preview.
|
||||
* - $submitted: By line with date and time.
|
||||
* - $title: Linked title.
|
||||
*
|
||||
* These two variables are provided for context.
|
||||
* - $comment: Full comment object.
|
||||
* - $node: Node object the comments are attached to.
|
||||
*
|
||||
* @see template_preprocess_comment()
|
||||
* @see theme_comment()
|
||||
*/
|
||||
?>
|
||||
<div class="comment<?php print ($comment->new) ? ' comment-new' : ''; print ' '. $status ?> clear-block">
|
||||
<?php print $picture ?>
|
||||
|
||||
<?php if ($comment->new): ?>
|
||||
<span class="new"><?php print $new ?></span>
|
||||
<?php endif; ?>
|
||||
|
||||
<h3><?php print $title ?></h3>
|
||||
|
||||
<div class="submitted">
|
||||
<?php print $submitted ?>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
<?php print $content ?>
|
||||
<?php if ($signature): ?>
|
||||
<div class="user-signature clear-block">
|
||||
<?php print $signature ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php print $links ?>
|
||||
</div>
|
Reference in a new issue