function fb_controls in Drupal for Facebook 7.3
Same name and namespace in other branches
- 6.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.
9 calls to fb_controls()
- fb_init in ./
fb.module - Implements hook_init().
- fb_user_fb in ./
fb_user.module - Implements hook_fb.
- fb_user_user_insert in ./
fb_user.module - Implements hook_user_insert.
- fb_user_user_login in ./
fb_user.module - Implements hook_user_login.
- _fb_user_check_and_goto in ./
fb_user.module - Detect whether facebook indicates the user has changed. If so, redirect.
File
- ./
fb.module, line 112 - This is the core required module of Drupal for Facebook.
Code
function fb_controls($control = NULL, $value = NULL) {
$controls =& drupal_static(__FUNCTION__);
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.
}