Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
/**
* @file
*
* This module provides some app-specific navigation to facebook apps. This
* is fairly experimental material. May change a lot in near future.
*
*/
/**
* Implementation of hook_fb.
*/
function fb_navigation_fb($fb, $fb_app, $op, &$return) {
if ($op == FB_OP_INITIALIZE) {
//drupal_set_message("fb_navigation_fb" . dpr($_GET, 1) . 'arg(0) = ' . dpr(arg(0), 1) . 'arg(1) = ' . dpr(arg(1), 1) . 'frontpage ' . dpr(variable_get('site_frontpage', 'node'), 1));
if ($_GET['q'] == drupal_get_normal_path(variable_get('site_frontpage', 'node'))) {
$fb_app_data = fb_app_get_data($fb_app);
$fb_navigation_data = $fb_app_data['fb_navigation'];
if ($fb->api_client->users_isAppAdded())
$front = $fb_navigation_data['front_added'];
else if ($fb->get_loggedin_user())
$front = $fb_navigation_data['front_loggedin'];
else
$front = $fb_navigation_data['front_anonymous'];
if ($front)
menu_set_active_item(drupal_get_normal_path($front));
}
}
}
/**
* Implementation of hook_form_alter.
*/
function fb_navigation_form_alter($form_id, &$form) {
// Add our settings to the fb_app edit form.
if (is_array($form['fb_app_data'])) {
$node = $form['#node'];
$fb_app_data = fb_app_get_data($node->fb_app);
$fb_navigation_data = $fb_app_data['fb_navigation'];
$form['fb_app_data']['fb_navigation'] = array('#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#title' => t('Facebook navigation settings'),
'#description' => t('Allows application-specific front page and navigation links.')
);
$form['fb_app_data']['fb_navigation']['front_anonymous'] =
array('#type' => 'textfield',
'#title' => t('Front page when user is not logged in'),
'#description' => t('Leave blank to use the site-wide front page.'),
'#default_value' => $fb_navigation_data['front_anonymous'],
);
$form['fb_app_data']['fb_navigation']['front_loggedin'] =
array('#type' => 'textfield',
'#title' => t('Front page when user is logged in, but has not added the app.'),
'#description' => t('Leave blank to use the site-wide front page.'),
'#default_value' => $fb_navigation_data['front_loggedin'],
);
$form['fb_app_data']['fb_navigation']['front_added'] =
array('#type' => 'textfield',
'#title' => t('Front page when user has added this application.'),
'#description' => t('Leave blank to use the site-wide front page.'),
'#default_value' => $fb_navigation_data['front_added'],
);
}
}
?>