Révision e9984459
Ajouté par Assos Assos il y a environ 8 ans
drupal7/sites/all/modules/webform/includes/webform.components.inc | ||
---|---|---|
197 | 197 |
} |
198 | 198 |
else { |
199 | 199 |
$rows[] = array(array('data' => t('No Components, add a component below.'), 'colspan' => 9)); |
200 |
// When there are no components, tabledrag.js will look to the add component |
|
201 |
// row to locate the weight column. Because of the name/form_key colspan |
|
202 |
// it will mis-count the columns and locate the Required column instead of |
|
203 |
// the Weight column. |
|
204 |
unset($add_form['data'][0]['colspan']); |
|
205 |
array_splice($add_form['data'], 1, 0, ' '); |
|
200 | 206 |
} |
201 | 207 |
|
202 | 208 |
// Append the add form if not already printed. |
... | ... | |
870 | 876 |
|
871 | 877 |
// Delete any conditionals dependent on this component. |
872 | 878 |
module_load_include('inc', 'webform', 'includes/webform.conditionals'); |
873 |
foreach ($node->webform['conditionals'] as $rgid => $conditional) { |
|
874 |
$delete_conditional = FALSE; |
|
879 |
foreach ($node->webform['conditionals'] as $rgid => &$conditional) { |
|
875 | 880 |
$specs = array( |
876 | 881 |
array( |
877 | 882 |
'field' => 'rules', |
... | ... | |
889 | 894 |
), |
890 | 895 |
); |
891 | 896 |
foreach ($specs as $spec) { |
892 |
$count = count($conditional[$spec['field']]); |
|
893 |
foreach ($conditional[$spec['field']] as $key => $thing) { |
|
897 |
$deleted = array(); |
|
898 |
$field = $spec['field']; |
|
899 |
foreach ($conditional[$field] as $key => $thing) { |
|
894 | 900 |
if ($thing[$spec['component_type']] === 'component' && $thing[$spec['component']] == $component['cid']) { |
895 |
if ($count == 1) { |
|
896 |
// Delete the conditional if this component is the only source or target. |
|
897 |
webform_conditional_delete($node, $conditional); |
|
898 |
break 2; |
|
899 |
} |
|
900 |
db_delete($spec['table']) |
|
901 |
->condition('nid', $node->nid) |
|
902 |
->condition('rgid', $rgid) |
|
903 |
->condition($spec['index'], $key) |
|
904 |
->execute(); |
|
905 |
$count--; |
|
901 |
$deleted[$key] = $key; |
|
902 |
unset($conditional[$field][$key]); |
|
906 | 903 |
} |
907 | 904 |
} |
905 |
if ($spec['field'] == 'rules') { |
|
906 |
// Rules deleted because of the source component being deleted may have left |
|
907 |
// empty sub-conditionals. Delete them, and then the entire rule group if |
|
908 |
// there aren't any rules left. |
|
909 |
$deleted += webform_delete_empty_subconditionals($conditional); |
|
910 |
} |
|
911 |
// Delete the conditional if this component is the only source / target. |
|
912 |
if (empty($conditional[$field])) { |
|
913 |
webform_conditional_delete($node, $conditional); |
|
914 |
break; // Loop exit. |
|
915 |
} |
|
916 |
// Remove the deleted rules / actions from the database. |
|
917 |
foreach ($deleted as $key) { |
|
918 |
db_delete($spec['table']) |
|
919 |
->condition('nid', $node->nid) |
|
920 |
->condition('rgid', $rgid) |
|
921 |
->condition($spec['index'], $key) |
|
922 |
->execute(); |
|
923 |
} |
|
908 | 924 |
} |
909 | 925 |
} |
910 | 926 |
|
Formats disponibles : Unified diff
Weekly update of contrib modules