function heartbeat_activity_form_callback in Heartbeat 7
Ajax callback function when Heartbeat Activity is posted as Profile Status.
1 string reference to 'heartbeat_activity_form_callback'
- heartbeat_activity_form in ./
heartbeat.entity.inc - Generate the heartbeat activity add/edit form. This entity form is always referenced to a stream.
File
- ./
heartbeat.entity.inc, line 278
Code
function heartbeat_activity_form_callback(&$form, &$form_state) {
$commands = array();
// If the user performs a Status update, the polling should
// prepend immediately, without showing a notification.
$args = $form_state['values']['uid'] == $GLOBALS['user']->uid ? array(
0,
) : array(
1,
);
// We also want the form to be a new form without any values.
$template_id = $form['#heartbeat_activity']->template->message_id;
$form_id = 'heartbeat_activity_form_' . $template_id;
$heartbeatStream = $form['#heartbeat_stream'];
$template = heartbeat_message_template_load($heartbeatStream->config->settings['show_status_form']);
$heartbeatActivity = new HeartbeatActivity(array(
'actor' => $GLOBALS['user'],
), $template);
// Allow the stream to modify the HeartbeatActivity object.
// This is mostly used to add some context to the logging.
$heartbeatStream
->modifyActivityMessage($heartbeatActivity);
$new_form_state = array();
$new_form_state['input'] = array();
$new_form_state['rebuild'] = TRUE;
$new_form = drupal_get_form($form_id . '_' . $_SERVER['REQUEST_TIME'], $heartbeatActivity, $heartbeatStream);
$commands[] = ajax_command_html(NULL, drupal_render($new_form));
$commands[] = ajax_command_invoke(NULL, 'heartbeatNotifyStreams', $args);
return array(
'#type' => 'ajax',
'#commands' => $commands,
);
}