<?php
$group = explode('/', current_path());
//We need to check permissions here because this block has been used explicitly in a quicktab and as such the page restrictions below don't apply
if(og_user_access('node', $group[1], 'administer group'))
{
require_once drupal_get_path('module', 'node') . '/node.pages.inc';
global $user;
$form_state = form_state_defaults();
$form_state['build_info']['args'][0] =  (object) array(
  'uid' => $user->uid,
  'name' => $user->name,
  'type' => 'message',
  'language' => 'und',
);
$form = drupal_build_form('message_node_form', $form_state);
$form['#action'] = '/node/add/message';
$form['og_group_ref']['und']['#attributes'] = array('class' =>array('hidden'));
$form['#suffix'] = '<script type="text/javascript">' . 
'jQuery(\'#edit-og-group-ref select option[value="' . arg(1) . '"]\').attr(\'selected\', \'selected\');' . 
'jQuery(\'#edit-og-group-ref\').addClass(\'hidden\');' . 
'</script>';
print drupal_render($form);
}
?>