function activity_comments_form in Activity 6.2
Same name and namespace in other branches
- 7 activity_comments/activity_comments.module \activity_comments_form()
Add comment form.
1 string reference to 'activity_comments_form'
- activity_comments_handler_field_comments::render in activity_comments/
views/ activity_comments_handler_field_comments.inc
File
- activity_comments/
activity_comments.module, line 130 - Provides comment handling for activity messages
Code
function activity_comments_form($form_state, $aid, $limit, $direction) {
$form['activity_form_items'] = array(
'#access' => user_access('activity post comments'),
'#prefix' => '<div class="container-inline activity-comment-add clear-block">',
'#suffix' => '</div>',
);
$form['activity_form_items']['activity_comment'] = array(
'#type' => 'textarea',
'#rows' => 2,
'#resizable' => FALSE,
'#attributes' => array(
'class' => 'activity-comment-text',
),
'#default_value' => t('Write a Comment'),
);
$form['aid'] = array(
'#type' => 'value',
'#value' => $aid,
);
$form['direction'] = array(
'#type' => 'value',
'#value' => $direction,
);
$form['activity_form_items']['activity_save_comment'] = array(
'#type' => 'submit',
'#value' => t('Add'),
'#ahah' => array(
'path' => 'activity/comments/insert',
'wrapper' => 'activity-comments-' . $aid,
'method' => 'replace',
'effect' => 'fade',
),
'#id' => 'activity-comment-save-comment-' . $aid,
);
// fetch all the comments for this
$result = db_query("SELECT ac.cid, ac.comment, ac.timestamp, ac.uid, u.name FROM {activity_comments} ac INNER JOIN {users} u ON ac.uid = u.uid WHERE ac.aid = %d ORDER BY timestamp %s", $aid, $direction);
$items = array();
while ($comment_obj = db_fetch_object($result)) {
$items[] = $comment_obj;
}
// put all the comments into a markup for the form
$form['comments'] = array(
'#value' => theme('activity_comments_comments', $aid, $items, $limit),
'#weight' => -10,
);
// show all
$form['show_all'] = array(
'#prefix' => '<span class="activity-comment-show-all">',
'#value' => '<a href="#">' . t('Show all !plural', array(
'!plural' => format_plural(count($items), '1 comment', '@count comments'),
)) . '</a>',
'#suffix' => '</span>',
'#weight' => -11,
'#access' => count($items) > $limit,
);
$form['#attributes'] = array(
'class' => 'activity_comment-comment-form',
);
// after build to add js
$form['#after_build'][] = 'activity_comments_add_js';
$form['#pre_render'][] = 'activity_comments_wrap';
return $form;
}