You are here

function panels_skinr_access_handler_display in Skinr 6.2

Same name and namespace in other branches
  1. 6 modules/panels.skinr.inc \panels_skinr_access_handler_display()

Skinr access handler.

Parameters

$op: What kind of action is being performed. Possible values:

  • "access skinr": access to edit skinr's selector
  • "access skinr classes": access to edit skinr's additional classes

&$form: Passes in the $form parameter from hook_form_alter().

$form_state: Passes in the $form_state parameter from hook_form_alter().

Return value

TRUE if we get access, FALSE if we don't.

Related topics

1 string reference to 'panels_skinr_access_handler_display'
panels_skinr_config in modules/panels.skinr.inc
Implementation of hook_skinr_config().

File

modules/panels.skinr.inc, line 100
Provide skinr handling for panels.module.

Code

function panels_skinr_access_handler_display($op, &$form, $form_state) {

  // We don't want the skinr settings form to appear on this form. We only want
  // to intercept it so we can save our cached data.
  // Since we're not using the form, we won't get our form submitter, so let's
  // add it manually.
  $form_id = $form['form_id']['#value'];
  switch ($form_id) {
    case 'panels_panel_context_edit_content':

      // Update and save button
      // Only add submit handler once.
      if (!in_array('skinr_ui_form_submit', $form['#submit'])) {
        $form['#submit'][] = 'skinr_ui_form_submit';
      }
      break;
    case 'page_manager_save_page_form':

      // Submitting a panel page.
      // Only add submit handler once.
      if (!in_array('skinr_ui_form_submit', $form['#submit'])) {
        $form['#submit'][] = 'skinr_ui_form_submit';
      }
      if (isset($form['save']['#submit']) && !in_array('skinr_ui_form_submit', $form['save']['#submit'])) {
        $form['save']['#submit'][] = 'skinr_ui_form_submit';
      }
      if (isset($form['cancel']['#submit']) && !in_array('skinr_ui_form_submit', $form['cancel']['#submit'])) {
        $form['cancel']['#submit'][] = 'skinr_ui_form_submit';
      }
      break;
    case 'panels_edit_display_form':

      // Only add submit handler once.
      if (!in_array('skinr_ui_form_submit', $form['#submit'])) {
        $form['#submit'][] = 'skinr_ui_form_submit';
      }
      if (isset($form['buttons']['submit']['#submit']) && !in_array('skinr_ui_form_submit', $form['buttons']['submit']['#submit'])) {
        $form['buttons']['submit']['#submit'][] = 'skinr_ui_form_submit';
      }
      break;
    default:

      // We only want to save or cancel on these other forms if we're dealing with a panel_page.
      if ($form_state['task']['name'] == 'panel_page') {

        // Only add submit handler once
        if (!in_array('skinr_ui_form_submit', $form['#submit'])) {
          $form['#submit'][] = 'skinr_ui_form_submit';
        }
        if (isset($form['buttons']['cancel']['#submit']) && !in_array('skinr_ui_form_submit', $form['buttons']['cancel']['#submit'])) {
          $form['buttons']['cancel']['#submit'][] = 'skinr_ui_form_submit';
        }
      }
      break;
  }
  return FALSE;
}