Commit 591b6624 authored by frjo's avatar frjo
Browse files

#847840: Allow other forms to be called through colorbox, patch by aufumy and modified by frjo.

parent 7ed4b9b7
......@@ -63,6 +63,11 @@ Go to "Administer" -> "Site configuration" -> "Colorbox" to find
all the configuration options.
Use the Views Colorbox Trigger field:
------------------------------------
TODO
Add a custom Colorbox style to your theme:
----------------------------------------
The easiest is to start with either the default style or one of the
......
......@@ -9,6 +9,8 @@
/**
* Allows to override Colorbox settings and style.
*
* Implementation of hook_colorbox_settings_alter().
*
* @param $settings
* An associative array of Colorbox settings. See the
* @link http://colorpowered.com/colorbox/ Colorbox documentation @endlink
......@@ -25,3 +27,22 @@ function hook_colorbox_settings_alter(&$settings, &$style) {
$style = 'mystyle';
}
}
/**
* Allow other modules to control access to forms opening in Colorbox.
*
* Implementation of hook_colorbox_form_access().
*
* @param $form_id
* The unique string identifying the current form.
*/
function hook_colorbox_form_access($form_id) {
$access = FALSE;
if ($form_id == 'forward_form') {
return user_access('access forward');
}
return $access;
}
......@@ -105,6 +105,9 @@ function colorbox_menu() {
* Colorbox menu access check.
*/
function _colorbox_form_page_access($form_id) {
$access = FALSE;
// First check if this is one of the forms Colorbox support out of the box.
switch ($form_id) {
case 'contact_site_form':
$access = user_access('access site-wide contact form');
......@@ -117,9 +120,15 @@ function _colorbox_form_page_access($form_id) {
case 'user_login_block':
$access = user_is_anonymous();
break;
default:
// All other forms get no access.
$access = FALSE;
}
// Invoke hook_colorbox_form_access for all modules.
if (!$access) {
foreach (module_implements('colorbox_form_access') as $module) {
if ($access = module_invoke($module, 'colorbox_form_access', $form_id)) {
return $access;
}
}
}
return $access;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment