Mailinglist
 All Data Structures Files Functions Variables Pages
MailinglistExportUI Class Reference

Place for common code for export_ui classes Forwards a lot of ctools_export_ui hooks to the exportable class. More...

Inheritance diagram for MailinglistExportUI:
Inheritance graph
[legend]
Collaboration diagram for MailinglistExportUI:
Collaboration graph
[legend]

Public Member Functions

ctools_export_ui
 edit_form (&$form, &$form_state)
 Implements ctools_export_ui::edit_form(). More...
 
 edit_form_validate (&$form, &$form_state)
 Implements ctools_export_ui::edit_form_validate(). More...
 
 edit_form_submit (&$form, &$form_state)
 Implements ctools_export_ui::edit_form_submit(). More...
 
 edit_save_form ($form_state)
 
 delete_form_submit (&$form_state)
 Implements ctools_export_ui::delete_form_submit(). More...
 

Detailed Description

Place for common code for export_ui classes Forwards a lot of ctools_export_ui hooks to the exportable class.

Definition at line 11 of file MailinglistExportUI.class.php.

Member Function Documentation

delete_form_submit ( $form_state)

Implements ctools_export_ui::delete_form_submit().

Hook into delete_form_submit to generate a hook for item ready to disappear.

Definition at line 140 of file MailinglistExportUI.class.php.

140  {
141  $item = $form_state['item'];
142  dpm($item, 'Delete');
143  $item->delete();
144  parent::delete_form_submit($form_state);
145  }
edit_form ( $form,
$form_state 
)

Implements ctools_export_ui::edit_form().

Todo:
Need to decide how to handle this: When building the form, we have in $form_state['item'] the value of the object for this form as read from the database to build up the form. The issue is that this does NOT reflect changes made in the form along the way until we get through Submit. The big issue is that if we change what type of object we want, we NEED to change the object to that time, so as to build the form for the needed values but the object in the form_state will not really be 'valid' as fields needed by the type (and provided by the form) may not be present. We also have a quandry on taking other values from the input, if we take them at form building time, they haven't (and can't) be validated (can't because we don't have form info to do the validation). Is it better to be missing some values, and others be stale, or to have more (but likely not all) values but from an unvalidated source.
Todo:
Should we do this? (see above), maybe just copy 'object_type'
Todo:
why doesn't this get copied?
Todo:
see if we can normally cache, and only disable cache if changing object type.

Definition at line 35 of file MailinglistExportUI.class.php.

References _mailinglist_object_factory(), and mailinglist_array_merge_recursive_distinct().

35  {
36  $form_state['orig_item'] = clone($form_state['item']);
37  // Check if we need to rebuild object to change its type.
38 
39  if (isset($form_state['input']['object_type']) && $form_state['input']['object_type'] != $form_state['item']->object_type) {
40  // Request Type different than current type lets change it to get right menu
41  $export_type = $form_state['item']->export_type;
42  $schema = ctools_export_get_schema($form_state['plugin']['schema']);
43  $data = (array) $form_state['item'];
45  $data = mailinglist_array_merge_recursive_distinct($data, $form_state['input']);
46  dpm($schema);
47  dpm($form_state);
48  dpm($data);
49  // Serialize the fields that need it
50  foreach ($schema['fields'] as $field => $field_schema) {
51  if (isset($field_schema['serialize']) && $field_schema['serialize']) {
52  $data[$field] = serialize($data[$field]);
53  }
54  }
55  $data = (object)$data;
56  $form_state['item'] = _mailinglist_object_factory($schema, $data);
57  $form_state['item']->export_type = $export_type;
58  }
59  parent::edit_form($form, $form_state);
60 
61  // disable caching as it gets in the way of changing the object's type.
63  $form_state['no_cache'] = TRUE;
64 
65  if (method_exists($form_state['item'], 'edit_form')) {
66  $form_state['item']->edit_form($form, $form_state);
67  }
68 
69  $form['info']['object_type_menu'] = array(
70  '#type' => 'hidden',
71  '#value' => isset($form_state['item']->object_type) ? $form_state['item']->object_type : NULL,
72  );
73  }
mailinglist_array_merge_recursive_distinct(array &$array1, array &$array2)
array_merge_recursive does indeed merge arrays, but it converts values with duplicate keys to arrays ...
_mailinglist_object_factory($schema, $data)
Builds an type variable object from a database table entry.

Here is the call graph for this function:

edit_form_submit ( $form,
$form_state 
)

Implements ctools_export_ui::edit_form_submit().

Definition at line 96 of file MailinglistExportUI.class.php.

96  {
97  dpm($form_state, 'mailinglist_export_ui::edit_form_submit');
98  // Do our hook before parent:: as parent copies over item, and there may be values there we want save in settings.
99  if (method_exists($form_state['item'], 'edit_form_submit')) {
100  $form_state['item']->edit_form_submit($form, $form_state);
101  }
102 
103  watchdog('mailinglist form', 'xx', array(), WATCHDOG_DEBUG );
104  watchdog('mailinglist state', 'xx', array(), WATCHDOG_DEBUG );
105  parent::edit_form_submit($form, $form_state);
106  }
edit_form_validate ( $form,
$form_state 
)

Implements ctools_export_ui::edit_form_validate().

Todo:
Why doesn't this flag the error?

Definition at line 78 of file MailinglistExportUI.class.php.

78  {
79  dpm($form_state, 'mailinglist_export_ui::edit_form_validate');
80  if ($form_state['input']['object_type_menu'] != $form_state['input']['object_type']) {
82  form_set_error('object_type', 'Type Changed, Check Settings!');
83  watchdog('Mailinglist', 'Type Change Verify', array(), WATCHDOG_DEBUG);
84  }
85 
86  parent::edit_form_validate($form, $form_state);
87 
88  if (method_exists($form_state['item'], 'edit_form_validate')) {
89  $form_state['item']->edit_form_validate($form, $form_state);
90  }
91  }
edit_save_form (   $form_state)

Definition at line 114 of file MailinglistExportUI.class.php.

114  {
115  dpm(debug_backtrace(), 'mailinglist_export_ui::edit_save_form()');
116 
117  // This call will end up doing the actual form save
118  parent::edit_save_form($form_state);
119 
120  $item = &$form_state['item'];
121  if ($form_state['op'] == 'add') {
122  $item->table = $this->plugin['schema']; // New objects don't seem to get a table item.
123  $item->created();
124  }
125  else {
126  $orig_item = $form_state['orig_item'];
127  if ($item->object_type != $orig_item->object_type) {
128  $item->changedType($orig_item);
129  }
130 
131  $item->edited($orig_item);
132  }
133  }

The documentation for this class was generated from the following file: