function linkedin_status_form_alter in LinkedIn Integration 6
Same name and namespace in other branches
- 7 linkedin_status/linkedin_status.module \linkedin_status_form_alter()
File
- linkedin_status/
linkedin_status.module, line 44 - Main hooks implementation for LinkedIn Profile module
Code
function linkedin_status_form_alter(&$form, $form_state, $form_id) {
// add posting form into event signup
if ($form_id == 'signup_form') {
global $user;
if (variable_get('linkedin_status_enabled_event_signup', '0') != '1' || !user_access('update LinkedIn status')) {
return;
}
else {
//node object is not at same key everytime, so iterate until we find it
$array = $form['#parameters'];
$node = new stdClass();
foreach ($array as $k) {
if (is_object($k) && isset($k->nid) && $k->type == 'event') {
$node = $k;
break;
}
else {
array_pop($array);
}
}
$form['collapse']['signup_user_form']['linkedin'] = drupal_retrieve_form('linkedin_status_update_form', $form_state, $user, $node);
array_unshift($form['#submit'], 'linkedin_status_update_form_submit');
//manually adding our submit handler
}
}
else {
//add posting form into nodes edit page and comments
if (isset($form['#node']) && $form['#node']->type . '_node_form' == $form_id || $form_id == 'comment_form' && $form['form_id']['#id'] == 'edit-comment-form') {
global $user;
$node = isset($form['#node']) ? $form['#node'] : node_load($form['nid']['#value']);
if (variable_get('linkedin_status_enabled_' . $node->type, '0') != '1' || !user_access('update LinkedIn status') || $form_id == 'comment_form' && variable_get('linkedin_status_enabled_comment', '0') != '1') {
return;
}
else {
$form['linkedin'] = drupal_retrieve_form('linkedin_status_update_form', $form_state, $user, $node);
array_unshift($form['#submit'], 'linkedin_status_update_form_submit');
}
}
}
return $form;
}