groups/modules/groups/groups_comment/groups_comment.module

47 lines
1.5 KiB
Plaintext

<?php
/**
* Implements hook_FORM_ID_form_alter().
*
* Override comment form.
*/
function groups_comment_form_comment_form_alter(&$form, &$form_state) {
global $user;
// Display the user's picture.
$wrapper = entity_metadata_wrapper('user', $user);
$path = empty($user->picture) ? variable_get('user_picture_default') : $wrapper->value()->picture->uri;
$form['user_picture'] = array(
'#theme' => 'image_style',
'#style_name' => '50x50_avatar',
'#path' => $path,
'#prefix' => '<div class="user-picture">',
'#suffix' => '</div>',
'#weight' => -20,
);
// hide subject field
$form['subject']['#access'] = False;
$form['author']['#access'] = False;
$form['comment_body'][LANGUAGE_NONE][0]['#placeholder'] = t('Write a comment...');
$form['comment_body'][LANGUAGE_NONE][0]['#resizable'] = False;
$form['comment_body'][LANGUAGE_NONE][0]['#rows'] = 3;
$form['comment_body'][LANGUAGE_NONE][0]['#title_display'] = 'invisible';
// remove preview button
unset($form['actions']['preview']);
}
/**
* Implements hook_text_format_alter.
*
* Set default text format to markdown for the group/body field.
*/
function groups_comment_text_format_alter(&$element) {
if ((isset($element['#bundle'])) && (isset($element['#field_name']))) {
if (($element['#bundle'] == 'comment_node_post') && ($element['#field_name'] == 'comment_body')) {
// set default value to markdown
$element['format']['format']['#default_value'] = 'markdown';
// hide text format filter
$element['format']['#access'] = FALSE;
}
}
}