ctools_access_ruleset_ui.class.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. class ctools_access_ruleset_ui extends ctools_export_ui {
  3. public function edit_form_context(&$form, &$form_state) {
  4. ctools_include('context-admin');
  5. ctools_context_admin_includes();
  6. ctools_add_css('ruleset');
  7. $form['right'] = array(
  8. '#prefix' => '<div class="ctools-right-container">',
  9. '#suffix' => '</div>',
  10. );
  11. $form['left'] = array(
  12. '#prefix' => '<div class="ctools-left-container clearfix">',
  13. '#suffix' => '</div>',
  14. );
  15. // Set this up and we can use CTools' Export UI's built in wizard caching,
  16. // which already has callbacks for the context cache under this name.
  17. $module = 'export_ui::' . $this->plugin['name'];
  18. $name = $this->edit_cache_get_key($form_state['item'], $form_state['form type']);
  19. ctools_context_add_context_form($module, $form, $form_state, $form['right']['contexts_table'], $form_state['item'], $name);
  20. ctools_context_add_required_context_form($module, $form, $form_state, $form['left']['required_contexts_table'], $form_state['item'], $name);
  21. ctools_context_add_relationship_form($module, $form, $form_state, $form['right']['relationships_table'], $form_state['item'], $name);
  22. }
  23. public function edit_form_rules(&$form, &$form_state) {
  24. // The 'access' UI passes everything via $form_state, unlike the 'context' UI.
  25. // The main difference is that one is about 3 years newer than the other.
  26. ctools_include('context');
  27. ctools_include('context-access-admin');
  28. $form_state['access'] = $form_state['item']->access;
  29. $form_state['contexts'] = ctools_context_load_contexts($form_state['item']);
  30. $form_state['module'] = 'ctools_export_ui';
  31. $form_state['callback argument'] = $form_state['object']->plugin['name'] . ':' . $form_state['object']->edit_cache_get_key($form_state['item'], $form_state['form type']);
  32. $form_state['no buttons'] = TRUE;
  33. $form = ctools_access_admin_form($form, $form_state);
  34. }
  35. public function edit_form_rules_submit(&$form, &$form_state) {
  36. $form_state['item']->access['logic'] = $form_state['values']['logic'];
  37. }
  38. public function edit_form_submit(&$form, &$form_state) {
  39. parent::edit_form_submit($form, $form_state);
  40. }
  41. }