function fb_controls in Drupal for Facebook 6.3
Same name and namespace in other branches
- 7.3 fb.module \fb_controls()
Controls are one way to customize the behavior of Drupal for Facebook modules.
Controls are stored as an array of flags. Each flag overrides a configurable or built-in behavior. Third-party modules can use this to provide exceptions to otherwise useful behavior. For example see fb_user.module, where this is used to suppress some behavior in off-line mode.
Controls take effect not just for the current page request, but also for ajax callbacks generated by the subsequent page.
Because ajax controls could be spoofed by a malicious client, flags should not enable any "risky" features. For example, fb_user.module provides a control to suppress the creation of account, but not a control to enable new accounts, as that would be a security risk.
8 calls to fb_controls()
- fb_init in ./
fb.module - Implements hook_init().
- fb_user_fb in ./
fb_user.module - Implementation of hook_fb.
- fb_user_footer in ./
fb_user.module - fb_user_user in ./
fb_user.module - Implementation of hook_user().
- _fb_user_create_local_account in ./
fb_user.module - Helper function to create local account for the currently authorized user.
File
- ./
fb.module, line 102 - This is the core required module of Drupal for Facebook.
Code
function fb_controls($control = NULL, $value = NULL) {
static $controls;
if (!isset($controls)) {
// Initialize.
if (isset($_REQUEST['fb_controls'])) {
// Comma separated list passed to ajax calls.
foreach (explode(',', $_REQUEST['fb_controls']) as $key) {
$controls[$key] = TRUE;
}
}
else {
$controls = array();
}
// @TODO - would a drupal_alter() be useful here?
}
if (isset($control)) {
if ($value === FALSE) {
unset($controls[$control]);
return;
}
elseif ($value === TRUE) {
$controls[$control] = TRUE;
}
return isset($controls[$control]) ? $controls[$control] : FALSE;
// Return requested control.
}
return array_keys($controls);
// Return all controls.
}