View source
<?php
function fb_invite_menu() {
$items['fb_invite'] = array(
'title' => 'Invite friends',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'fb_invite_invite_form',
1,
),
'access callback' => 'fb_invite_access_cb',
'type' => MENU_CALLBACK,
);
return $items;
}
function fb_invite_access_cb() {
extract(fb_vars());
if ($fb_app) {
return TRUE;
}
else {
return FALSE;
}
}
function fb_invite_invite_form($form, &$form_state, $account) {
global $user;
drupal_add_js(drupal_get_path('module', 'fb_invite') . '/fb_invite.js', array(
'type' => 'file',
'scope' => 'header',
'group' => JS_LIBRARY,
));
drupal_add_js(array(
'fb_invite' => array(
'site_name' => variable_get('site_name', 'Drupal'),
),
), 'setting');
drupal_add_css(drupal_get_path('module', 'fb_invite') . '/fb_invite.theme.css');
extract(fb_vars());
if ($fb && $fbu) {
$form['no_js'] = array(
'#type' => 'markup',
'#markup' => t('Enable javascript to invite your facebook friends.'),
'#prefix' => '<p class="fb_hide">',
'#suffix' => '</p>',
);
$form['fb_invite'] = array(
'#prefix' => '<table id="fb_invite_wrapper" class="fb_connected"><tr>',
'#suffix' => '</tr></table>',
);
$header = t('Invite Friends');
$form['fb_invite']['friend_template'] = array(
'#prefix' => '<td><table id="fb_invite_friends_wrapper" style="clear:both;"><th colspan=3>' . $header . '</th><tr id="fb_invite_friend_template" style="display:none;">',
'#suffix' => '</tr></table></td>',
);
$form['fb_invite']['friend_template']['fb_invite_img'] = array(
'#type' => 'markup',
'#prefix' => '<td>',
'#suffix' => '</td>',
'#markup' => '<img class="fb_invite_img" src=""></img>',
);
$form['fb_invite']['friend_template']['fb_invite_name'] = array(
'#type' => 'markup',
'#prefix' => '<td>',
'#suffix' => '</td>',
'#markup' => '<span class="fb_invite_name"></span>',
);
$form['fb_invite']['friend_template']['fb_invite_button'] = array(
'#prefix' => '<td>',
'#suffix' => '</td>',
'#type' => 'button',
'#value' => t('Invite'),
'#attributes' => array(
'class' => array(
'fb_invite_button',
),
),
);
$header = t('Friends on %site', array(
'%site' => variable_get('site_name', 'Drupal'),
));
$form['fb_invite']['user_template'] = array(
'#prefix' => '<td><table id="fb_invite_user_wrapper" style="clear:both;"><th colspan=2>' . $header . '</th><tr id="fb_invite_user_template" style="display:none;">',
'#suffix' => '</tr></table></td>',
);
$form['fb_invite']['user_template']['fb_invite_img'] = array(
'#type' => 'markup',
'#prefix' => '<td>',
'#suffix' => '</td>',
'#markup' => '<img class="fb_invite_img" src=""></img>',
);
$form['fb_invite']['user_template']['fb_invite_name'] = array(
'#type' => 'markup',
'#prefix' => '<td>',
'#suffix' => '</td>',
'#markup' => "<span class=\"fb_invite_name\"></span>",
);
if (module_exists('fb_user')) {
foreach ($form['fb_invite']['user_template'] as $key => $markup) {
$form['fb_invite']['user_template'][$key]['#prefix'] = $markup['#prefix'] . '<a href="" class="fb_invite_user_link">';
$form['fb_invite']['user_template'][$key]['#suffix'] = '</a>' . $markup['#suffix'];
}
}
}
elseif ($fb && !$fbu) {
$form['connect'] = array(
'#type' => 'markup',
'#markup' => theme('fb_login_button', array(
'text' => t('Connect to invite your Facebook friends'),
)),
);
}
return $form;
}