Révision 8c72e82a
Ajouté par Assos Assos il y a environ 7 ans
drupal7/sites/all/modules/webform/webform.drush.inc | ||
---|---|---|
2 | 2 |
|
3 | 3 |
/** |
4 | 4 |
* @file |
5 |
* Implementation of hook_drush_command().
|
|
5 |
* Functions relating to Drush integration.
|
|
6 | 6 |
*/ |
7 | 7 |
|
8 |
/** |
|
9 |
* Implements hook_drush_command(). |
|
10 |
*/ |
|
8 | 11 |
function webform_drush_command() { |
9 | 12 |
return array( |
10 | 13 |
'webform-export' => array( |
... | ... | |
46 | 49 |
* Exports a webform via drush, useful for large data dumps that would otherwise |
47 | 50 |
* time out due to memory consumption. |
48 | 51 |
* |
49 |
* @param int $nid |
|
52 |
* @param bool|int $nid
|
|
50 | 53 |
* Node ID of the webform that we want to export. |
54 |
* |
|
55 |
* @return |
|
56 |
* The value returned from drush_set_error(). |
|
51 | 57 |
*/ |
52 | 58 |
function drush_webform_export($nid = FALSE) { |
53 | 59 |
if (!$nid) { |
... | ... | |
102 | 108 |
array('!opt' => "range-$option_name", '!val' => $option_value))); |
103 | 109 |
} |
104 | 110 |
} |
105 |
|
|
111 |
|
|
106 | 112 |
// Determine the range type based on provided input, if not explicitly set. |
107 | 113 |
if (empty($options['range']['range_type'])) { |
108 | 114 |
$options['range']['range_type'] = isset($options['range']['start']) |
109 |
? 'range'
|
|
110 |
: (isset($options['range']['latest'])
|
|
111 |
? 'latest'
|
|
112 |
: 'all');
|
|
115 |
? 'range' |
|
116 |
: (isset($options['range']['latest']) |
|
117 |
? 'latest' |
|
118 |
: 'all'); |
|
113 | 119 |
} |
114 |
|
|
120 |
|
|
115 | 121 |
// Set defaults for any missing range arguments. |
116 | 122 |
switch ($options['range']['range_type']) { |
117 | 123 |
case 'latest': |
... | ... | |
134 | 140 |
} |
135 | 141 |
|
136 | 142 |
// Get the preferred completion type |
137 |
$options['range']['completion_type'] = drush_get_option('completion-type', NULL);
|
|
143 |
$options['range']['completion_type'] = drush_get_option('completion-type', NULL); |
|
138 | 144 |
if (isset($options['range']['completion_type']) && !in_array($options['range']['completion_type'], array('finished', 'draft', 'all'))) { |
139 | 145 |
return drush_set_error('Unsupported completion-type. The available options are "finished", "draft", or "all".'); |
140 | 146 |
} |
... | ... | |
189 | 195 |
} |
190 | 196 |
|
191 | 197 |
/** |
192 |
* Implements hook_drush_sql_sync_sanitize. |
|
198 |
* Implements hook_drush_sql_sync_sanitize().
|
|
193 | 199 |
*/ |
194 | 200 |
function webform_drush_sql_sync_sanitize($source) { |
201 |
// Fetch list of all table. |
|
202 |
$all_tables = drush_sql_get_class()->listTables(); |
|
203 |
$tables_to_truncate = array('webform_submitted_data', 'webform_submissions'); |
|
204 |
|
|
205 |
$truncate_webform_tables_query = array(); |
|
206 |
foreach ($tables_to_truncate as $table) { |
|
207 |
if (in_array($table, $all_tables, TRUE)) { |
|
208 |
$truncate_webform_tables_query[] = 'TRUNCATE ' . $table . ';'; |
|
209 |
} |
|
210 |
} |
|
211 |
|
|
195 | 212 |
drush_sql_register_post_sync_op('webform_submitted_data', |
196 | 213 |
dt('Delete all data submitted to webforms (depending on the site config, may contain sensitive data).'), |
197 |
"TRUNCATE webform_submitted_data; TRUNCATE webform_submissions;");
|
|
214 |
implode(' ', $truncate_webform_tables_query));
|
|
198 | 215 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules