@@ -23,13 +23,13 @@ discard block |
||
23 | 23 | const TEMPLATE_MARKER = '-eTemplate-'; |
24 | 24 | |
25 | 25 | /** |
26 | - * List of steps. Key is the function, value is the translated title. |
|
27 | - */ |
|
26 | + * List of steps. Key is the function, value is the translated title. |
|
27 | + */ |
|
28 | 28 | public $steps; |
29 | 29 | |
30 | 30 | /** |
31 | - * List of eTemplates to use for each step. You can override this with your own etemplates steps. |
|
32 | - */ |
|
31 | + * List of eTemplates to use for each step. You can override this with your own etemplates steps. |
|
32 | + */ |
|
33 | 33 | protected $step_templates = array( |
34 | 34 | 'wizard_step30' => 'importexport.wizard_basic_import_csv.sample_file', |
35 | 35 | 'wizard_step40' => 'importexport.wizard_basic_import_csv.choosesepncharset', |
@@ -39,19 +39,19 @@ discard block |
||
39 | 39 | |
40 | 40 | |
41 | 41 | /** |
42 | - * Destination fields for the mapping |
|
43 | - * Key is the field name, value is the human version |
|
44 | - */ |
|
42 | + * Destination fields for the mapping |
|
43 | + * Key is the field name, value is the human version |
|
44 | + */ |
|
45 | 45 | protected $mapping_fields = array(); |
46 | 46 | |
47 | 47 | /** |
48 | - * List of conditions your plugin supports |
|
49 | - */ |
|
48 | + * List of conditions your plugin supports |
|
49 | + */ |
|
50 | 50 | protected $conditions = array(); |
51 | 51 | |
52 | 52 | /** |
53 | - * List of actions your plugin supports |
|
54 | - */ |
|
53 | + * List of actions your plugin supports |
|
54 | + */ |
|
55 | 55 | protected $actions = array(); |
56 | 56 | |
57 | 57 | /** |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
71 | - * Take a sample CSV file. It will be processed in later steps |
|
72 | - */ |
|
71 | + * Take a sample CSV file. It will be processed in later steps |
|
72 | + */ |
|
73 | 73 | function wizard_step30(&$content, &$sel_options, &$readonlys, &$preserv) |
74 | 74 | { |
75 | 75 | if($this->debug) error_log(get_class($this) . '::wizard_step30->$content '.print_r($content,true)); |
@@ -263,11 +263,11 @@ discard block |
||
263 | 263 | } |
264 | 264 | |
265 | 265 | /** |
266 | - * Process the sample file, get the fields out of it, then allow them to be mapped onto |
|
267 | - * the fields the destination understands. Also, set any translations to be done to the field. |
|
268 | - * |
|
269 | - * You can use the eTemplate |
|
270 | - */ |
|
266 | + * Process the sample file, get the fields out of it, then allow them to be mapped onto |
|
267 | + * the fields the destination understands. Also, set any translations to be done to the field. |
|
268 | + * |
|
269 | + * You can use the eTemplate |
|
270 | + */ |
|
271 | 271 | function wizard_step50(&$content, &$sel_options, &$readonlys, &$preserv) |
272 | 272 | { |
273 | 273 | if($this->debug) error_log(get_class($this) . '::wizard_step50->$content '.print_r($content,true)); |
@@ -348,8 +348,8 @@ discard block |
||
348 | 348 | } |
349 | 349 | |
350 | 350 | /** |
351 | - * Edit conditions |
|
352 | - */ |
|
351 | + * Edit conditions |
|
352 | + */ |
|
353 | 353 | function wizard_step55(&$content, &$sel_options, &$readonlys, &$preserv) |
354 | 354 | { |
355 | 355 | if($this->debug) error_log(get_class($this) . '::wizard_step55->$content '.print_r($content,true)); |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | */ |
73 | 73 | function wizard_step30(&$content, &$sel_options, &$readonlys, &$preserv) |
74 | 74 | { |
75 | - if($this->debug) error_log(get_class($this) . '::wizard_step30->$content '.print_r($content,true)); |
|
75 | + if ($this->debug) error_log(get_class($this).'::wizard_step30->$content '.print_r($content, true)); |
|
76 | 76 | // return from step30 |
77 | 77 | if ($content['step'] == 'wizard_step30') |
78 | 78 | { |
@@ -80,17 +80,17 @@ discard block |
||
80 | 80 | { |
81 | 81 | case 'next': |
82 | 82 | // Move sample file to temp |
83 | - if($content['file']['tmp_name']) { |
|
83 | + if ($content['file']['tmp_name']) { |
|
84 | 84 | Api\Cache::setSession($content['application'], 'csvfile', $content['file']['tmp_name']); |
85 | 85 | } |
86 | 86 | unset($content['file']); |
87 | - return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1); |
|
87 | + return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], 1); |
|
88 | 88 | case 'previous' : |
89 | - return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],-1); |
|
89 | + return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], -1); |
|
90 | 90 | case 'finish': |
91 | 91 | return 'wizard_finish'; |
92 | 92 | default : |
93 | - return $this->wizard_step30($content,$sel_options,$readonlys,$preserv); |
|
93 | + return $this->wizard_step30($content, $sel_options, $readonlys, $preserv); |
|
94 | 94 | } |
95 | 95 | } |
96 | 96 | // init step30 |
@@ -117,57 +117,57 @@ discard block |
||
117 | 117 | */ |
118 | 118 | function wizard_step40(&$content, &$sel_options, &$readonlys, &$preserv) |
119 | 119 | { |
120 | - if($this->debug) error_log(get_class($this) . '::wizard_step40->$content '.print_r($content,true)); |
|
120 | + if ($this->debug) error_log(get_class($this).'::wizard_step40->$content '.print_r($content, true)); |
|
121 | 121 | // return from step40 |
122 | 122 | if ($content['step'] == 'wizard_step40') { |
123 | 123 | switch (array_search('pressed', $content['button'])) |
124 | 124 | { |
125 | 125 | case 'next': |
126 | 126 | // Process sample file for fields |
127 | - if (Api\Cache::getSession($content['application'],'csvfile') && |
|
128 | - ($handle = fopen(Api\Cache::getSession($content['application'],'csvfile'), "rb")) !== FALSE |
|
127 | + if (Api\Cache::getSession($content['application'], 'csvfile') && |
|
128 | + ($handle = fopen(Api\Cache::getSession($content['application'], 'csvfile'), "rb")) !== FALSE |
|
129 | 129 | ) { |
130 | 130 | $data = fgetcsv($handle, 8000, $content['fieldsep']); |
131 | 131 | //error_log(array2string($data)); |
132 | 132 | fclose($handle); |
133 | 133 | |
134 | 134 | // Remove & forget file |
135 | - unlink(Api\Cache::getSession($content['application'],'csvfile')); |
|
135 | + unlink(Api\Cache::getSession($content['application'], 'csvfile')); |
|
136 | 136 | Api\Cache::setSession($content['application'], 'csvfile', ''); |
137 | - $content['csv_fields'] = Api\Translation::convert($data,$content['charset']); |
|
137 | + $content['csv_fields'] = Api\Translation::convert($data, $content['charset']); |
|
138 | 138 | |
139 | 139 | // Reset field mapping for new file |
140 | 140 | $content['field_mapping'] = array(); |
141 | 141 | |
142 | 142 | // Try to match automatically |
143 | 143 | $english = array(); |
144 | - foreach($content['csv_fields'] as $index => $field) { |
|
145 | - if($content['field_mapping'][$index]) continue; |
|
144 | + foreach ($content['csv_fields'] as $index => $field) { |
|
145 | + if ($content['field_mapping'][$index]) continue; |
|
146 | 146 | $best_match = ''; |
147 | 147 | $best_match_value = 0; |
148 | - foreach($this->mapping_fields as $key => $field_name) { |
|
149 | - if(is_array($field_name)) continue; |
|
150 | - if(strcasecmp($field, $field_name) == 0 || strcasecmp($field,$key) == 0) { |
|
148 | + foreach ($this->mapping_fields as $key => $field_name) { |
|
149 | + if (is_array($field_name)) continue; |
|
150 | + if (strcasecmp($field, $field_name) == 0 || strcasecmp($field, $key) == 0) { |
|
151 | 151 | $content['field_mapping'][$index] = $key; |
152 | 152 | continue 2; |
153 | 153 | } |
154 | 154 | // Check english also |
155 | - if($GLOBALS['egw_info']['user']['preferences']['common']['lang'] != 'en' && !isset($english[$field_name])) { |
|
155 | + if ($GLOBALS['egw_info']['user']['preferences']['common']['lang'] != 'en' && !isset($english[$field_name])) { |
|
156 | 156 | $msg_id = Api\Translation::get_message_id($field_name, $content['application']); |
157 | 157 | } |
158 | - if($msg_id) { |
|
158 | + if ($msg_id) { |
|
159 | 159 | $english[$field_name] = Api\Translation::read('en', $content['application'], $msg_id); |
160 | 160 | } else { |
161 | 161 | $english[$field_name] = false; |
162 | 162 | } |
163 | - if($english[$field_name] && strcasecmp($field, $english[$field_name]) == 0) { |
|
163 | + if ($english[$field_name] && strcasecmp($field, $english[$field_name]) == 0) { |
|
164 | 164 | $content['field_mapping'][$index] = $key; |
165 | 165 | continue 2; |
166 | 166 | } |
167 | 167 | |
168 | 168 | // Check for similar but slightly different |
169 | 169 | $match = 0; |
170 | - if(similar_text(strtolower($field), strtolower($field_name), $match) && |
|
170 | + if (similar_text(strtolower($field), strtolower($field_name), $match) && |
|
171 | 171 | $match > 85 && |
172 | 172 | $match > $best_match_value |
173 | 173 | ) { |
@@ -176,20 +176,20 @@ discard block |
||
176 | 176 | } |
177 | 177 | |
178 | 178 | } |
179 | - if($best_match) { |
|
179 | + if ($best_match) { |
|
180 | 180 | $content['field_mapping'][$index] = $best_match; |
181 | 181 | } |
182 | 182 | } |
183 | - } elseif(!$content['csv_fields'] && $content['plugin_options']['csv_fields']) { |
|
183 | + } elseif (!$content['csv_fields'] && $content['plugin_options']['csv_fields']) { |
|
184 | 184 | $content['csv_fields'] = $content['plugin_options']['csv_fields']; |
185 | 185 | } |
186 | - return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1); |
|
186 | + return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], 1); |
|
187 | 187 | case 'previous' : |
188 | - return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],-1); |
|
188 | + return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], -1); |
|
189 | 189 | case 'finish': |
190 | 190 | return 'wizard_finish'; |
191 | 191 | default : |
192 | - return $this->wizard_step40($content,$sel_options,$readonlys,$preserv); |
|
192 | + return $this->wizard_step40($content, $sel_options, $readonlys, $preserv); |
|
193 | 193 | } |
194 | 194 | } |
195 | 195 | // init step40 |
@@ -199,17 +199,17 @@ discard block |
||
199 | 199 | $content['step'] = 'wizard_step40'; |
200 | 200 | |
201 | 201 | // If editing an existing definition, these will be in plugin_options |
202 | - if(!$content['fieldsep'] && $content['plugin_options']['fieldsep']) { |
|
202 | + if (!$content['fieldsep'] && $content['plugin_options']['fieldsep']) { |
|
203 | 203 | $content['fieldsep'] = $content['plugin_options']['fieldsep']; |
204 | 204 | } elseif (!$content['fieldsep']) { |
205 | 205 | $content['fieldsep'] = ';'; |
206 | 206 | } |
207 | - if(!$content['charset'] && $content['plugin_options']['charset']) { |
|
207 | + if (!$content['charset'] && $content['plugin_options']['charset']) { |
|
208 | 208 | $content['charset'] = $content['plugin_options']['charset']; |
209 | 209 | } |
210 | - if(!array_key_exists('num_header_lines', $content)) |
|
210 | + if (!array_key_exists('num_header_lines', $content)) |
|
211 | 211 | { |
212 | - if(is_array($content['plugin_options']) && array_key_exists('num_header_lines', $content['plugin_options'])) |
|
212 | + if (is_array($content['plugin_options']) && array_key_exists('num_header_lines', $content['plugin_options'])) |
|
213 | 213 | { |
214 | 214 | $content['num_header_lines'] = $content['plugin_options']['num_header_lines']; |
215 | 215 | } |
@@ -219,10 +219,10 @@ discard block |
||
219 | 219 | $content['num_header_lines'] = 1; |
220 | 220 | } |
221 | 221 | } |
222 | - if(!$content['update_cats'] && $content['plugin_options']['update_cats']) { |
|
222 | + if (!$content['update_cats'] && $content['plugin_options']['update_cats']) { |
|
223 | 223 | $content['update_cats'] = $content['plugin_options']['update_cats']; |
224 | 224 | } |
225 | - if(!array_key_exists('convert', $content) && is_array($content['plugin_options']) && array_key_exists('convert', $content['plugin_options'])) { |
|
225 | + if (!array_key_exists('convert', $content) && is_array($content['plugin_options']) && array_key_exists('convert', $content['plugin_options'])) { |
|
226 | 226 | $content['convert'] = $content['plugin_options']['convert']; |
227 | 227 | } |
228 | 228 | else |
@@ -231,24 +231,24 @@ discard block |
||
231 | 231 | $content['convert'] = 1; |
232 | 232 | } |
233 | 233 | |
234 | - $sel_options['charset'] = Api\Translation::get_installed_charsets()+ |
|
234 | + $sel_options['charset'] = Api\Translation::get_installed_charsets() + |
|
235 | 235 | array( |
236 | 236 | 'user' => lang('User preference'), |
237 | 237 | ); |
238 | 238 | |
239 | 239 | // Add in extra allowed charsets |
240 | 240 | $config = Api\Config::read('importexport'); |
241 | - $extra_charsets = array_intersect(explode(',',$config['import_charsets']), mb_list_encodings()); |
|
242 | - if($extra_charsets) |
|
241 | + $extra_charsets = array_intersect(explode(',', $config['import_charsets']), mb_list_encodings()); |
|
242 | + if ($extra_charsets) |
|
243 | 243 | { |
244 | - $sel_options['charset'] += array(lang('Extra encodings') => array_combine($extra_charsets,$extra_charsets)); |
|
244 | + $sel_options['charset'] += array(lang('Extra encodings') => array_combine($extra_charsets, $extra_charsets)); |
|
245 | 245 | } |
246 | 246 | $sel_options['convert'] = array( |
247 | 247 | 0 => lang('Database values'), |
248 | 248 | 1 => lang('Human friendly values') |
249 | 249 | ); |
250 | 250 | $preserv = $content; |
251 | - if($this->mapping_fields['cat_id']) { |
|
251 | + if ($this->mapping_fields['cat_id']) { |
|
252 | 252 | $sel_options['update_cats'] = array( |
253 | 253 | 'add' => lang('Add'), |
254 | 254 | 'replace'=> lang('Replace') |
@@ -270,18 +270,18 @@ discard block |
||
270 | 270 | */ |
271 | 271 | function wizard_step50(&$content, &$sel_options, &$readonlys, &$preserv) |
272 | 272 | { |
273 | - if($this->debug) error_log(get_class($this) . '::wizard_step50->$content '.print_r($content,true)); |
|
273 | + if ($this->debug) error_log(get_class($this).'::wizard_step50->$content '.print_r($content, true)); |
|
274 | 274 | // return from step50 |
275 | 275 | if ($content['step'] == 'wizard_step50') |
276 | 276 | { |
277 | 277 | unset($content['field_mapping']); |
278 | 278 | unset($content['field_conversion']); |
279 | - foreach($content['mapping'] as $field) |
|
279 | + foreach ($content['mapping'] as $field) |
|
280 | 280 | { |
281 | 281 | $index = $field['index']; |
282 | - foreach(array('conversion'=>'field_conversion', 'field' => 'field_mapping') as $id => $dest) |
|
282 | + foreach (array('conversion'=>'field_conversion', 'field' => 'field_mapping') as $id => $dest) |
|
283 | 283 | { |
284 | - if(trim($field[$id]) != '' && $field[$id] !== '--NONE--') |
|
284 | + if (trim($field[$id]) != '' && $field[$id] !== '--NONE--') |
|
285 | 285 | { |
286 | 286 | $content[$dest][$index] = trim($field[$id]); |
287 | 287 | } |
@@ -291,13 +291,13 @@ discard block |
||
291 | 291 | switch (array_search('pressed', $content['button'])) |
292 | 292 | { |
293 | 293 | case 'next': |
294 | - return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1); |
|
294 | + return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], 1); |
|
295 | 295 | case 'previous' : |
296 | - return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],-1); |
|
296 | + return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], -1); |
|
297 | 297 | case 'finish': |
298 | 298 | return 'wizard_finish'; |
299 | 299 | default : |
300 | - return $this->wizard_step50($content,$sel_options,$readonlys,$preserv); |
|
300 | + return $this->wizard_step50($content, $sel_options, $readonlys, $preserv); |
|
301 | 301 | } |
302 | 302 | } |
303 | 303 | // init step50 |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | $content['step'] = 'wizard_step50'; |
308 | 308 | |
309 | 309 | $content['mapping'] = array(false); |
310 | - if(array_key_exists('field_mapping', $content)) |
|
310 | + if (array_key_exists('field_mapping', $content)) |
|
311 | 311 | { |
312 | 312 | $field = $content['field_mapping']; |
313 | 313 | $conversion = $content['field_conversion']; |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | $conversion = $content['plugin_options']['field_conversion']; |
319 | 319 | } |
320 | 320 | $empties = 1; |
321 | - foreach($content['csv_fields'] as $index => $title) |
|
321 | + foreach ($content['csv_fields'] as $index => $title) |
|
322 | 322 | { |
323 | 323 | $content['mapping'][] = array( |
324 | 324 | 'index' => $index, |
@@ -326,15 +326,15 @@ discard block |
||
326 | 326 | 'field' => $field[$index], |
327 | 327 | 'conversion' => $conversion[$index] |
328 | 328 | ); |
329 | - if(strstr($title,lang('Extra %1'))) $empties++; |
|
329 | + if (strstr($title, lang('Extra %1'))) $empties++; |
|
330 | 330 | } |
331 | - while($empties <= 3) |
|
331 | + while ($empties <= 3) |
|
332 | 332 | { |
333 | 333 | $content['mapping'][] = array( |
334 | 334 | 'index' => $index + $empties, |
335 | 335 | 'title' => lang('Extra %1', $empties), |
336 | - 'field' => $field[$index+$empties], |
|
337 | - 'conversion' => $conversion[$index+$empties] |
|
336 | + 'field' => $field[$index + $empties], |
|
337 | + 'conversion' => $conversion[$index + $empties] |
|
338 | 338 | ); |
339 | 339 | $empties++; |
340 | 340 | } |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | */ |
353 | 353 | function wizard_step55(&$content, &$sel_options, &$readonlys, &$preserv) |
354 | 354 | { |
355 | - if($this->debug) error_log(get_class($this) . '::wizard_step55->$content '.print_r($content,true)); |
|
355 | + if ($this->debug) error_log(get_class($this).'::wizard_step55->$content '.print_r($content, true)); |
|
356 | 356 | |
357 | 357 | // return from step55 |
358 | 358 | if ($content['step'] == 'wizard_step55') |
@@ -360,8 +360,8 @@ discard block |
||
360 | 360 | |
361 | 361 | // Clear conditions that don't do anything |
362 | 362 | array_shift($content['conditions']); |
363 | - foreach($content['conditions'] as $key => &$condition) { |
|
364 | - if(($condition['true']['action'] == 'none' || !$condition['true']['action']) |
|
363 | + foreach ($content['conditions'] as $key => &$condition) { |
|
364 | + if (($condition['true']['action'] == 'none' || !$condition['true']['action']) |
|
365 | 365 | && ($condition['false']['action'] == 'none' || !$condition['false']['action']) && |
366 | 366 | !$condition['string'] |
367 | 367 | ) { |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | } |
371 | 371 | |
372 | 372 | // Check for true without false, or false without true - set to 'none' |
373 | - elseif($condition['true']['action'] == '' && $condition['false']['action'] != '' || |
|
373 | + elseif ($condition['true']['action'] == '' && $condition['false']['action'] != '' || |
|
374 | 374 | $condition['true']['action'] != '' && $condition['false']['action'] == '' || |
375 | 375 | !$condition['true'] || !$condition['false'] |
376 | 376 | ) |
@@ -382,9 +382,9 @@ discard block |
||
382 | 382 | switch (array_search('pressed', $content['button'])) |
383 | 383 | { |
384 | 384 | case 'next': |
385 | - return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1); |
|
385 | + return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], 1); |
|
386 | 386 | case 'previous' : |
387 | - return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],-1); |
|
387 | + return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], -1); |
|
388 | 388 | case 'finish': |
389 | 389 | return 'wizard_finish'; |
390 | 390 | case 'add': |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | $content['conditions'][] = array('string' => ''); |
394 | 394 | return 'wizard_step55'; |
395 | 395 | default : |
396 | - return $this->wizard_step55($content,$sel_options,$readonlys,$preserv); |
|
396 | + return $this->wizard_step55($content, $sel_options, $readonlys, $preserv); |
|
397 | 397 | break; |
398 | 398 | } |
399 | 399 | } |
@@ -401,18 +401,18 @@ discard block |
||
401 | 401 | $content['text'] = $this->steps['wizard_step55']; |
402 | 402 | $content['step'] = 'wizard_step55'; |
403 | 403 | |
404 | - if(!$content['conditions'] && $content['plugin_options']['conditions']) { |
|
404 | + if (!$content['conditions'] && $content['plugin_options']['conditions']) { |
|
405 | 405 | $content['conditions'] = $content['plugin_options']['conditions']; |
406 | 406 | } |
407 | 407 | $preserv = $content; |
408 | 408 | |
409 | - foreach($content['field_mapping'] as $field) { |
|
409 | + foreach ($content['field_mapping'] as $field) { |
|
410 | 410 | $sel_options['string'][$field] = $this->mapping_fields[$field]; |
411 | - if(!$sel_options['string'][$field]) |
|
411 | + if (!$sel_options['string'][$field]) |
|
412 | 412 | { |
413 | - foreach($this->mapping_fields as $fields) |
|
413 | + foreach ($this->mapping_fields as $fields) |
|
414 | 414 | { |
415 | - if(is_array($fields) && $fields[$field]) |
|
415 | + if (is_array($fields) && $fields[$field]) |
|
416 | 416 | { |
417 | 417 | $sel_options['string'][$field] = $fields[$field]; |
418 | 418 | } |
@@ -72,7 +72,10 @@ discard block |
||
72 | 72 | */ |
73 | 73 | function wizard_step30(&$content, &$sel_options, &$readonlys, &$preserv) |
74 | 74 | { |
75 | - if($this->debug) error_log(get_class($this) . '::wizard_step30->$content '.print_r($content,true)); |
|
75 | + if($this->debug) |
|
76 | + { |
|
77 | + error_log(get_class($this) . '::wizard_step30->$content '.print_r($content,true)); |
|
78 | + } |
|
76 | 79 | // return from step30 |
77 | 80 | if ($content['step'] == 'wizard_step30') |
78 | 81 | { |
@@ -80,7 +83,8 @@ discard block |
||
80 | 83 | { |
81 | 84 | case 'next': |
82 | 85 | // Move sample file to temp |
83 | - if($content['file']['tmp_name']) { |
|
86 | + if($content['file']['tmp_name']) |
|
87 | + { |
|
84 | 88 | Api\Cache::setSession($content['application'], 'csvfile', $content['file']['tmp_name']); |
85 | 89 | } |
86 | 90 | unset($content['file']); |
@@ -117,9 +121,13 @@ discard block |
||
117 | 121 | */ |
118 | 122 | function wizard_step40(&$content, &$sel_options, &$readonlys, &$preserv) |
119 | 123 | { |
120 | - if($this->debug) error_log(get_class($this) . '::wizard_step40->$content '.print_r($content,true)); |
|
124 | + if($this->debug) |
|
125 | + { |
|
126 | + error_log(get_class($this) . '::wizard_step40->$content '.print_r($content,true)); |
|
127 | + } |
|
121 | 128 | // return from step40 |
122 | - if ($content['step'] == 'wizard_step40') { |
|
129 | + if ($content['step'] == 'wizard_step40') |
|
130 | + { |
|
123 | 131 | switch (array_search('pressed', $content['button'])) |
124 | 132 | { |
125 | 133 | case 'next': |
@@ -141,26 +149,40 @@ discard block |
||
141 | 149 | |
142 | 150 | // Try to match automatically |
143 | 151 | $english = array(); |
144 | - foreach($content['csv_fields'] as $index => $field) { |
|
145 | - if($content['field_mapping'][$index]) continue; |
|
152 | + foreach($content['csv_fields'] as $index => $field) |
|
153 | + { |
|
154 | + if($content['field_mapping'][$index]) |
|
155 | + { |
|
156 | + continue; |
|
157 | + } |
|
146 | 158 | $best_match = ''; |
147 | 159 | $best_match_value = 0; |
148 | - foreach($this->mapping_fields as $key => $field_name) { |
|
149 | - if(is_array($field_name)) continue; |
|
150 | - if(strcasecmp($field, $field_name) == 0 || strcasecmp($field,$key) == 0) { |
|
160 | + foreach($this->mapping_fields as $key => $field_name) |
|
161 | + { |
|
162 | + if(is_array($field_name)) |
|
163 | + { |
|
164 | + continue; |
|
165 | + } |
|
166 | + if(strcasecmp($field, $field_name) == 0 || strcasecmp($field,$key) == 0) |
|
167 | + { |
|
151 | 168 | $content['field_mapping'][$index] = $key; |
152 | 169 | continue 2; |
153 | 170 | } |
154 | 171 | // Check english also |
155 | - if($GLOBALS['egw_info']['user']['preferences']['common']['lang'] != 'en' && !isset($english[$field_name])) { |
|
172 | + if($GLOBALS['egw_info']['user']['preferences']['common']['lang'] != 'en' && !isset($english[$field_name])) |
|
173 | + { |
|
156 | 174 | $msg_id = Api\Translation::get_message_id($field_name, $content['application']); |
157 | 175 | } |
158 | - if($msg_id) { |
|
176 | + if($msg_id) |
|
177 | + { |
|
159 | 178 | $english[$field_name] = Api\Translation::read('en', $content['application'], $msg_id); |
160 | - } else { |
|
179 | + } |
|
180 | + else |
|
181 | + { |
|
161 | 182 | $english[$field_name] = false; |
162 | 183 | } |
163 | - if($english[$field_name] && strcasecmp($field, $english[$field_name]) == 0) { |
|
184 | + if($english[$field_name] && strcasecmp($field, $english[$field_name]) == 0) |
|
185 | + { |
|
164 | 186 | $content['field_mapping'][$index] = $key; |
165 | 187 | continue 2; |
166 | 188 | } |
@@ -176,11 +198,14 @@ discard block |
||
176 | 198 | } |
177 | 199 | |
178 | 200 | } |
179 | - if($best_match) { |
|
201 | + if($best_match) |
|
202 | + { |
|
180 | 203 | $content['field_mapping'][$index] = $best_match; |
181 | 204 | } |
182 | 205 | } |
183 | - } elseif(!$content['csv_fields'] && $content['plugin_options']['csv_fields']) { |
|
206 | + } |
|
207 | + elseif(!$content['csv_fields'] && $content['plugin_options']['csv_fields']) |
|
208 | + { |
|
184 | 209 | $content['csv_fields'] = $content['plugin_options']['csv_fields']; |
185 | 210 | } |
186 | 211 | return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1); |
@@ -199,12 +224,16 @@ discard block |
||
199 | 224 | $content['step'] = 'wizard_step40'; |
200 | 225 | |
201 | 226 | // If editing an existing definition, these will be in plugin_options |
202 | - if(!$content['fieldsep'] && $content['plugin_options']['fieldsep']) { |
|
227 | + if(!$content['fieldsep'] && $content['plugin_options']['fieldsep']) |
|
228 | + { |
|
203 | 229 | $content['fieldsep'] = $content['plugin_options']['fieldsep']; |
204 | - } elseif (!$content['fieldsep']) { |
|
230 | + } |
|
231 | + elseif (!$content['fieldsep']) |
|
232 | + { |
|
205 | 233 | $content['fieldsep'] = ';'; |
206 | 234 | } |
207 | - if(!$content['charset'] && $content['plugin_options']['charset']) { |
|
235 | + if(!$content['charset'] && $content['plugin_options']['charset']) |
|
236 | + { |
|
208 | 237 | $content['charset'] = $content['plugin_options']['charset']; |
209 | 238 | } |
210 | 239 | if(!array_key_exists('num_header_lines', $content)) |
@@ -219,10 +248,12 @@ discard block |
||
219 | 248 | $content['num_header_lines'] = 1; |
220 | 249 | } |
221 | 250 | } |
222 | - if(!$content['update_cats'] && $content['plugin_options']['update_cats']) { |
|
251 | + if(!$content['update_cats'] && $content['plugin_options']['update_cats']) |
|
252 | + { |
|
223 | 253 | $content['update_cats'] = $content['plugin_options']['update_cats']; |
224 | 254 | } |
225 | - if(!array_key_exists('convert', $content) && is_array($content['plugin_options']) && array_key_exists('convert', $content['plugin_options'])) { |
|
255 | + if(!array_key_exists('convert', $content) && is_array($content['plugin_options']) && array_key_exists('convert', $content['plugin_options'])) |
|
256 | + { |
|
226 | 257 | $content['convert'] = $content['plugin_options']['convert']; |
227 | 258 | } |
228 | 259 | else |
@@ -248,12 +279,15 @@ discard block |
||
248 | 279 | 1 => lang('Human friendly values') |
249 | 280 | ); |
250 | 281 | $preserv = $content; |
251 | - if($this->mapping_fields['cat_id']) { |
|
282 | + if($this->mapping_fields['cat_id']) |
|
283 | + { |
|
252 | 284 | $sel_options['update_cats'] = array( |
253 | 285 | 'add' => lang('Add'), |
254 | 286 | 'replace'=> lang('Replace') |
255 | 287 | ); |
256 | - } else { |
|
288 | + } |
|
289 | + else |
|
290 | + { |
|
257 | 291 | $content['no_cats'] = true; |
258 | 292 | } |
259 | 293 | unset ($preserv['button']); |
@@ -270,7 +304,10 @@ discard block |
||
270 | 304 | */ |
271 | 305 | function wizard_step50(&$content, &$sel_options, &$readonlys, &$preserv) |
272 | 306 | { |
273 | - if($this->debug) error_log(get_class($this) . '::wizard_step50->$content '.print_r($content,true)); |
|
307 | + if($this->debug) |
|
308 | + { |
|
309 | + error_log(get_class($this) . '::wizard_step50->$content '.print_r($content,true)); |
|
310 | + } |
|
274 | 311 | // return from step50 |
275 | 312 | if ($content['step'] == 'wizard_step50') |
276 | 313 | { |
@@ -326,7 +363,10 @@ discard block |
||
326 | 363 | 'field' => $field[$index], |
327 | 364 | 'conversion' => $conversion[$index] |
328 | 365 | ); |
329 | - if(strstr($title,lang('Extra %1'))) $empties++; |
|
366 | + if(strstr($title,lang('Extra %1'))) |
|
367 | + { |
|
368 | + $empties++; |
|
369 | + } |
|
330 | 370 | } |
331 | 371 | while($empties <= 3) |
332 | 372 | { |
@@ -352,7 +392,10 @@ discard block |
||
352 | 392 | */ |
353 | 393 | function wizard_step55(&$content, &$sel_options, &$readonlys, &$preserv) |
354 | 394 | { |
355 | - if($this->debug) error_log(get_class($this) . '::wizard_step55->$content '.print_r($content,true)); |
|
395 | + if($this->debug) |
|
396 | + { |
|
397 | + error_log(get_class($this) . '::wizard_step55->$content '.print_r($content,true)); |
|
398 | + } |
|
356 | 399 | |
357 | 400 | // return from step55 |
358 | 401 | if ($content['step'] == 'wizard_step55') |
@@ -360,7 +403,8 @@ discard block |
||
360 | 403 | |
361 | 404 | // Clear conditions that don't do anything |
362 | 405 | array_shift($content['conditions']); |
363 | - foreach($content['conditions'] as $key => &$condition) { |
|
406 | + foreach($content['conditions'] as $key => &$condition) |
|
407 | + { |
|
364 | 408 | if(($condition['true']['action'] == 'none' || !$condition['true']['action']) |
365 | 409 | && ($condition['false']['action'] == 'none' || !$condition['false']['action']) && |
366 | 410 | !$condition['string'] |
@@ -373,8 +417,7 @@ discard block |
||
373 | 417 | elseif($condition['true']['action'] == '' && $condition['false']['action'] != '' || |
374 | 418 | $condition['true']['action'] != '' && $condition['false']['action'] == '' || |
375 | 419 | !$condition['true'] || !$condition['false'] |
376 | - ) |
|
377 | - { |
|
420 | + ) { |
|
378 | 421 | $condition[$condition['true']['action'] == '' ? 'true' : 'false']['action'] = "none"; |
379 | 422 | } |
380 | 423 | } |
@@ -401,12 +444,14 @@ discard block |
||
401 | 444 | $content['text'] = $this->steps['wizard_step55']; |
402 | 445 | $content['step'] = 'wizard_step55'; |
403 | 446 | |
404 | - if(!$content['conditions'] && $content['plugin_options']['conditions']) { |
|
447 | + if(!$content['conditions'] && $content['plugin_options']['conditions']) |
|
448 | + { |
|
405 | 449 | $content['conditions'] = $content['plugin_options']['conditions']; |
406 | 450 | } |
407 | 451 | $preserv = $content; |
408 | 452 | |
409 | - foreach($content['field_mapping'] as $field) { |
|
453 | + foreach($content['field_mapping'] as $field) |
|
454 | + { |
|
410 | 455 | $sel_options['string'][$field] = $this->mapping_fields[$field]; |
411 | 456 | if(!$sel_options['string'][$field]) |
412 | 457 | { |
@@ -29,23 +29,23 @@ discard block |
||
29 | 29 | |
30 | 30 | if (ini_get('session.save_handler') == 'files' && !is_writable(ini_get('session.save_path')) && is_dir('/tmp') && is_writable('/tmp')) |
31 | 31 | { |
32 | - ini_set('session.save_path','/tmp'); // regular users may have no rights to apache's session dir |
|
32 | + ini_set('session.save_path', '/tmp'); // regular users may have no rights to apache's session dir |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | // Include PEAR::Console_Getopt |
36 | 36 | require_once 'Console/Getopt.php'; |
37 | 37 | |
38 | 38 | // Define exit codes for errors |
39 | -define('HEADER_NOT_FOUND',9); |
|
40 | -define('NO_ARGS',10); |
|
41 | -define('INVALID_OPTION',11); |
|
39 | +define('HEADER_NOT_FOUND', 9); |
|
40 | +define('NO_ARGS', 10); |
|
41 | +define('INVALID_OPTION', 11); |
|
42 | 42 | |
43 | 43 | // Reading the incoming arguments - same as $argv |
44 | 44 | $args = Console_Getopt::readPHPArgv(); |
45 | 45 | |
46 | 46 | // Make sure we got them (for non CLI binaries) |
47 | 47 | if (PEAR::isError($args)) { |
48 | - fwrite(STDERR,"importexport_cli: ".$args->getMessage()."\n".$usage); |
|
48 | + fwrite(STDERR, "importexport_cli: ".$args->getMessage()."\n".$usage); |
|
49 | 49 | exit(NO_ARGS); |
50 | 50 | } |
51 | 51 | |
@@ -63,15 +63,15 @@ discard block |
||
63 | 63 | ); |
64 | 64 | |
65 | 65 | // Convert the arguments to options - check for the first argument |
66 | -if ( realpath($_SERVER['argv'][0]) == __FILE__ ) { |
|
67 | - $options = Console_Getopt::getOpt($args,$short_opts,$long_opts); |
|
66 | +if (realpath($_SERVER['argv'][0]) == __FILE__) { |
|
67 | + $options = Console_Getopt::getOpt($args, $short_opts, $long_opts); |
|
68 | 68 | } else { |
69 | - $options = Console_Getopt::getOpt2($args,$short_opts,$long_opts); |
|
69 | + $options = Console_Getopt::getOpt2($args, $short_opts, $long_opts); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | // Check the options are valid |
73 | 73 | if (PEAR::isError($options)) { |
74 | - fwrite(STDERR,"importexport_cli: ".$options->getMessage()."\n".$usage."\n"); |
|
74 | + fwrite(STDERR, "importexport_cli: ".$options->getMessage()."\n".$usage."\n"); |
|
75 | 75 | exit(INVALID_OPTION); |
76 | 76 | } |
77 | 77 | |
@@ -98,13 +98,13 @@ discard block |
||
98 | 98 | $dryrun = true; |
99 | 99 | break; |
100 | 100 | default : |
101 | - fwrite (STDERR,$usage."\n"); |
|
101 | + fwrite(STDERR, $usage."\n"); |
|
102 | 102 | exit(INVALID_OPTION); |
103 | 103 | } |
104 | 104 | } |
105 | 105 | // check file |
106 | -if ( !$user || !$password ) { |
|
107 | - fwrite(STDERR,'importexport_cli: You have to supply a username / password'."\n".$usage); |
|
106 | +if (!$user || !$password) { |
|
107 | + fwrite(STDERR, 'importexport_cli: You have to supply a username / password'."\n".$usage); |
|
108 | 108 | exit(INVALID_OPTION); |
109 | 109 | } |
110 | 110 | |
@@ -117,12 +117,12 @@ discard block |
||
117 | 117 | 'nonavbar' => True, |
118 | 118 | 'currentapp' => 'importexport', |
119 | 119 | 'autocreate_session_callback' => 'import_export_access', |
120 | - 'login' => $user . '@' . $domain, |
|
120 | + 'login' => $user.'@'.$domain, |
|
121 | 121 | 'passwd' => $password, |
122 | 122 | ); |
123 | 123 | if (!is_readable($path_to_egroupware.'/header.inc.php')) |
124 | 124 | { |
125 | - fwrite(STDERR,"importexport.php: Could not find '$path_to_egroupware/header.inc.php', exiting !!!\n"); |
|
125 | + fwrite(STDERR, "importexport.php: Could not find '$path_to_egroupware/header.inc.php', exiting !!!\n"); |
|
126 | 126 | exit(HEADER_NOT_FOUND); |
127 | 127 | } |
128 | 128 | include($path_to_egroupware.'/header.inc.php'); |
@@ -130,13 +130,13 @@ discard block |
||
130 | 130 | // check file |
131 | 131 | if (!is_readable($file)) |
132 | 132 | { |
133 | - fwrite(STDERR,"importexport_cli: ". $file. ' is not readable'."\n"); |
|
133 | + fwrite(STDERR, "importexport_cli: ".$file.' is not readable'."\n"); |
|
134 | 134 | exit(INVALID_OPTION); |
135 | 135 | } |
136 | 136 | |
137 | 137 | $definition = new importexport_definition($definition); |
138 | -if( $definition->get_identifier() < 1 ) { |
|
139 | - fwrite(STDERR,"importexport_cli: Definition not found! \n"); |
|
138 | +if ($definition->get_identifier() < 1) { |
|
139 | + fwrite(STDERR, "importexport_cli: Definition not found! \n"); |
|
140 | 140 | exit(INVALID_OPTION); |
141 | 141 | } |
142 | 142 | |
@@ -147,8 +147,8 @@ discard block |
||
147 | 147 | |
148 | 148 | $po = new $definition->plugin; |
149 | 149 | |
150 | -$resource = fopen( $file, 'r' ); |
|
151 | -$po->$type( $resource, $definition ); |
|
150 | +$resource = fopen($file, 'r'); |
|
151 | +$po->$type($resource, $definition); |
|
152 | 152 | |
153 | 153 | exit(); |
154 | 154 |
@@ -23,7 +23,8 @@ discard block |
||
23 | 23 | --dry-run no real action, just console output |
24 | 24 | \n"; |
25 | 25 | |
26 | -if (php_sapi_name() != 'cli') { |
|
26 | +if (php_sapi_name() != 'cli') |
|
27 | +{ |
|
27 | 28 | die('This script only runs form command line'); |
28 | 29 | } |
29 | 30 | |
@@ -44,7 +45,8 @@ discard block |
||
44 | 45 | $args = Console_Getopt::readPHPArgv(); |
45 | 46 | |
46 | 47 | // Make sure we got them (for non CLI binaries) |
47 | -if (PEAR::isError($args)) { |
|
48 | +if (PEAR::isError($args)) |
|
49 | +{ |
|
48 | 50 | fwrite(STDERR,"importexport_cli: ".$args->getMessage()."\n".$usage); |
49 | 51 | exit(NO_ARGS); |
50 | 52 | } |
@@ -63,22 +65,28 @@ discard block |
||
63 | 65 | ); |
64 | 66 | |
65 | 67 | // Convert the arguments to options - check for the first argument |
66 | -if ( realpath($_SERVER['argv'][0]) == __FILE__ ) { |
|
68 | +if ( realpath($_SERVER['argv'][0]) == __FILE__ ) |
|
69 | +{ |
|
67 | 70 | $options = Console_Getopt::getOpt($args,$short_opts,$long_opts); |
68 | -} else { |
|
71 | +} |
|
72 | +else |
|
73 | +{ |
|
69 | 74 | $options = Console_Getopt::getOpt2($args,$short_opts,$long_opts); |
70 | 75 | } |
71 | 76 | |
72 | 77 | // Check the options are valid |
73 | -if (PEAR::isError($options)) { |
|
78 | +if (PEAR::isError($options)) |
|
79 | +{ |
|
74 | 80 | fwrite(STDERR,"importexport_cli: ".$options->getMessage()."\n".$usage."\n"); |
75 | 81 | exit(INVALID_OPTION); |
76 | 82 | } |
77 | 83 | |
78 | 84 | $domain = 'default'; |
79 | 85 | $dryrun = false; |
80 | -foreach ($options[0] as $option) { |
|
81 | - switch ($option[0]) { |
|
86 | +foreach ($options[0] as $option) |
|
87 | +{ |
|
88 | + switch ($option[0]) |
|
89 | + { |
|
82 | 90 | case '--file' : |
83 | 91 | $file = $option[1]; |
84 | 92 | break; |
@@ -103,7 +111,8 @@ discard block |
||
103 | 111 | } |
104 | 112 | } |
105 | 113 | // check file |
106 | -if ( !$user || !$password ) { |
|
114 | +if ( !$user || !$password ) |
|
115 | +{ |
|
107 | 116 | fwrite(STDERR,'importexport_cli: You have to supply a username / password'."\n".$usage); |
108 | 117 | exit(INVALID_OPTION); |
109 | 118 | } |
@@ -135,7 +144,8 @@ discard block |
||
135 | 144 | } |
136 | 145 | |
137 | 146 | $definition = new importexport_definition($definition); |
138 | -if( $definition->get_identifier() < 1 ) { |
|
147 | +if( $definition->get_identifier() < 1 ) |
|
148 | +{ |
|
139 | 149 | fwrite(STDERR,"importexport_cli: Definition not found! \n"); |
140 | 150 | exit(INVALID_OPTION); |
141 | 151 | } |
@@ -12,9 +12,9 @@ discard block |
||
12 | 12 | $setup_info['admin']['name'] = 'admin'; |
13 | 13 | $setup_info['admin']['version'] = '16.1'; |
14 | 14 | $setup_info['admin']['app_order'] = 1; |
15 | -$setup_info['admin']['tables'] = array('egw_admin_queue','egw_admin_remote'); |
|
15 | +$setup_info['admin']['tables'] = array('egw_admin_queue', 'egw_admin_remote'); |
|
16 | 16 | $setup_info['admin']['enable'] = 1; |
17 | -$setup_info['admin']['index'] = 'admin.admin_ui.index&ajax=true'; |
|
17 | +$setup_info['admin']['index'] = 'admin.admin_ui.index&ajax=true'; |
|
18 | 18 | |
19 | 19 | $setup_info['admin']['author'][] = array( |
20 | 20 | 'name' => 'eGroupWare coreteam', |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | 'url' => 'www.egroupware.org' |
28 | 28 | ); |
29 | 29 | |
30 | -$setup_info['admin']['license'] = 'GPL'; |
|
30 | +$setup_info['admin']['license'] = 'GPL'; |
|
31 | 31 | $setup_info['admin']['description'] = 'EGroupware administration application'; |
32 | 32 | |
33 | 33 | /* The hooks this app includes, needed for hooks registration */ |
@@ -46,5 +46,5 @@ |
||
46 | 46 | // Dependencies for this app to work |
47 | 47 | $setup_info['admin']['depends'][] = array( |
48 | 48 | 'appname' => 'api', |
49 | - 'versions' => Array('16.1') |
|
49 | + 'versions' => array('16.1') |
|
50 | 50 | ); |
@@ -15,37 +15,37 @@ |
||
15 | 15 | $phpgw_baseline = array( |
16 | 16 | 'egw_admin_queue' => array( |
17 | 17 | 'fd' => array( |
18 | - 'cmd_id' => array('type' => 'auto','nullable' => False), |
|
19 | - 'cmd_uid' => array('type' => 'ascii','precision' => '64','nullable' => False), |
|
20 | - 'cmd_creator' => array('type' => 'int','meta' => 'user','precision' => '4','nullable' => False), |
|
21 | - 'cmd_creator_email' => array('type' => 'varchar','precision' => '128','nullable' => False), |
|
22 | - 'cmd_created' => array('type' => 'int','meta' => 'timestamp','precision' => '8','nullable' => False), |
|
23 | - 'cmd_type' => array('type' => 'ascii','precision' => '32','nullable' => False,'default' => 'admin_cmd'), |
|
24 | - 'cmd_status' => array('type' => 'int','precision' => '1'), |
|
25 | - 'cmd_scheduled' => array('type' => 'int','meta' => 'timestamp','precision' => '8'), |
|
26 | - 'cmd_modified' => array('type' => 'int','meta' => 'timestamp','precision' => '8'), |
|
27 | - 'cmd_modifier' => array('type' => 'int','meta' => 'user','precision' => '4'), |
|
28 | - 'cmd_modifier_email' => array('type' => 'varchar','precision' => '128'), |
|
29 | - 'cmd_error' => array('type' => 'varchar','precision' => '255'), |
|
30 | - 'cmd_errno' => array('type' => 'int','precision' => '4'), |
|
31 | - 'cmd_requested' => array('type' => 'int','precision' => '4'), |
|
32 | - 'cmd_requested_email' => array('type' => 'varchar','precision' => '128'), |
|
33 | - 'cmd_comment' => array('type' => 'varchar','precision' => '255'), |
|
34 | - 'cmd_data' => array('type' => 'ascii','precision' => '16384'), |
|
35 | - 'remote_id' => array('type' => 'int','precision' => '4') |
|
18 | + 'cmd_id' => array('type' => 'auto', 'nullable' => False), |
|
19 | + 'cmd_uid' => array('type' => 'ascii', 'precision' => '64', 'nullable' => False), |
|
20 | + 'cmd_creator' => array('type' => 'int', 'meta' => 'user', 'precision' => '4', 'nullable' => False), |
|
21 | + 'cmd_creator_email' => array('type' => 'varchar', 'precision' => '128', 'nullable' => False), |
|
22 | + 'cmd_created' => array('type' => 'int', 'meta' => 'timestamp', 'precision' => '8', 'nullable' => False), |
|
23 | + 'cmd_type' => array('type' => 'ascii', 'precision' => '32', 'nullable' => False, 'default' => 'admin_cmd'), |
|
24 | + 'cmd_status' => array('type' => 'int', 'precision' => '1'), |
|
25 | + 'cmd_scheduled' => array('type' => 'int', 'meta' => 'timestamp', 'precision' => '8'), |
|
26 | + 'cmd_modified' => array('type' => 'int', 'meta' => 'timestamp', 'precision' => '8'), |
|
27 | + 'cmd_modifier' => array('type' => 'int', 'meta' => 'user', 'precision' => '4'), |
|
28 | + 'cmd_modifier_email' => array('type' => 'varchar', 'precision' => '128'), |
|
29 | + 'cmd_error' => array('type' => 'varchar', 'precision' => '255'), |
|
30 | + 'cmd_errno' => array('type' => 'int', 'precision' => '4'), |
|
31 | + 'cmd_requested' => array('type' => 'int', 'precision' => '4'), |
|
32 | + 'cmd_requested_email' => array('type' => 'varchar', 'precision' => '128'), |
|
33 | + 'cmd_comment' => array('type' => 'varchar', 'precision' => '255'), |
|
34 | + 'cmd_data' => array('type' => 'ascii', 'precision' => '16384'), |
|
35 | + 'remote_id' => array('type' => 'int', 'precision' => '4') |
|
36 | 36 | ), |
37 | 37 | 'pk' => array('cmd_id'), |
38 | 38 | 'fk' => array(), |
39 | - 'ix' => array('cmd_status','cmd_scheduled'), |
|
39 | + 'ix' => array('cmd_status', 'cmd_scheduled'), |
|
40 | 40 | 'uc' => array('cmd_uid') |
41 | 41 | ), |
42 | 42 | 'egw_admin_remote' => array( |
43 | 43 | 'fd' => array( |
44 | - 'remote_id' => array('type' => 'auto','nullable' => False), |
|
45 | - 'remote_name' => array('type' => 'varchar','precision' => '64','nullable' => False), |
|
46 | - 'remote_hash' => array('type' => 'ascii','precision' => '32','nullable' => False), |
|
47 | - 'remote_url' => array('type' => 'ascii','precision' => '128','nullable' => False), |
|
48 | - 'remote_domain' => array('type' => 'ascii','precision' => '64','nullable' => False) |
|
44 | + 'remote_id' => array('type' => 'auto', 'nullable' => False), |
|
45 | + 'remote_name' => array('type' => 'varchar', 'precision' => '64', 'nullable' => False), |
|
46 | + 'remote_hash' => array('type' => 'ascii', 'precision' => '32', 'nullable' => False), |
|
47 | + 'remote_url' => array('type' => 'ascii', 'precision' => '128', 'nullable' => False), |
|
48 | + 'remote_domain' => array('type' => 'ascii', 'precision' => '64', 'nullable' => False) |
|
49 | 49 | ), |
50 | 50 | 'pk' => array('remote_id'), |
51 | 51 | 'fk' => array(), |
@@ -20,29 +20,29 @@ discard block |
||
20 | 20 | |
21 | 21 | function admin_upgrade1_4() |
22 | 22 | { |
23 | - $GLOBALS['egw_setup']->oProc->CreateTable('egw_admin_queue',array( |
|
23 | + $GLOBALS['egw_setup']->oProc->CreateTable('egw_admin_queue', array( |
|
24 | 24 | 'fd' => array( |
25 | 25 | 'cmd_id' => array('type' => 'auto'), |
26 | - 'cmd_uid' => array('type' => 'varchar','precision' => '255','nullable' => False), |
|
27 | - 'cmd_creator' => array('type' => 'int','precision' => '4','nullable' => False), |
|
28 | - 'cmd_creator_email' => array('type' => 'varchar','precision' => '128','nullable' => False), |
|
29 | - 'cmd_created' => array('type' => 'int','precision' => '8','nullable' => False), |
|
30 | - 'cmd_type' => array('type' => 'varchar','precision' => '32','nullable' => False,'default' => 'admin_cmd'), |
|
31 | - 'cmd_status' => array('type' => 'int','precision' => '1'), |
|
32 | - 'cmd_scheduled' => array('type' => 'int','precision' => '8'), |
|
33 | - 'cmd_modified' => array('type' => 'int','precision' => '8'), |
|
34 | - 'cmd_modifier' => array('type' => 'int','precision' => '4'), |
|
35 | - 'cmd_modifier_email' => array('type' => 'varchar','precision' => '128'), |
|
36 | - 'cmd_error' => array('type' => 'varchar','precision' => '255'), |
|
37 | - 'cmd_errno' => array('type' => 'int','precision' => '4'), |
|
38 | - 'cmd_requested' => array('type' => 'int','precision' => '4'), |
|
39 | - 'cmd_requested_email' => array('type' => 'varchar','precision' => '128'), |
|
40 | - 'cmd_comment' => array('type' => 'varchar','precision' => '255'), |
|
26 | + 'cmd_uid' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False), |
|
27 | + 'cmd_creator' => array('type' => 'int', 'precision' => '4', 'nullable' => False), |
|
28 | + 'cmd_creator_email' => array('type' => 'varchar', 'precision' => '128', 'nullable' => False), |
|
29 | + 'cmd_created' => array('type' => 'int', 'precision' => '8', 'nullable' => False), |
|
30 | + 'cmd_type' => array('type' => 'varchar', 'precision' => '32', 'nullable' => False, 'default' => 'admin_cmd'), |
|
31 | + 'cmd_status' => array('type' => 'int', 'precision' => '1'), |
|
32 | + 'cmd_scheduled' => array('type' => 'int', 'precision' => '8'), |
|
33 | + 'cmd_modified' => array('type' => 'int', 'precision' => '8'), |
|
34 | + 'cmd_modifier' => array('type' => 'int', 'precision' => '4'), |
|
35 | + 'cmd_modifier_email' => array('type' => 'varchar', 'precision' => '128'), |
|
36 | + 'cmd_error' => array('type' => 'varchar', 'precision' => '255'), |
|
37 | + 'cmd_errno' => array('type' => 'int', 'precision' => '4'), |
|
38 | + 'cmd_requested' => array('type' => 'int', 'precision' => '4'), |
|
39 | + 'cmd_requested_email' => array('type' => 'varchar', 'precision' => '128'), |
|
40 | + 'cmd_comment' => array('type' => 'varchar', 'precision' => '255'), |
|
41 | 41 | 'cmd_data' => array('type' => 'blob') |
42 | 42 | ), |
43 | 43 | 'pk' => array('cmd_id'), |
44 | 44 | 'fk' => array(), |
45 | - 'ix' => array('cmd_status','cmd_scheduled'), |
|
45 | + 'ix' => array('cmd_status', 'cmd_scheduled'), |
|
46 | 46 | 'uc' => array('cmd_uid') |
47 | 47 | )); |
48 | 48 | return $GLOBALS['setup_info']['admin']['currentver'] = '1.5.001'; |
@@ -51,13 +51,13 @@ discard block |
||
51 | 51 | |
52 | 52 | function admin_upgrade1_5_001() |
53 | 53 | { |
54 | - $GLOBALS['egw_setup']->oProc->CreateTable('egw_admin_remote',array( |
|
54 | + $GLOBALS['egw_setup']->oProc->CreateTable('egw_admin_remote', array( |
|
55 | 55 | 'fd' => array( |
56 | 56 | 'remote_id' => array('type' => 'auto'), |
57 | - 'remote_name' => array('type' => 'varchar','precision' => '64','nullable' => False), |
|
58 | - 'remote_hash' => array('type' => 'varchar','precision' => '32','nullable' => False), |
|
59 | - 'remote_url' => array('type' => 'varchar','precision' => '128','nullable' => False), |
|
60 | - 'remote_domain' => array('type' => 'varchar','precision' => '64','nullable' => False) |
|
57 | + 'remote_name' => array('type' => 'varchar', 'precision' => '64', 'nullable' => False), |
|
58 | + 'remote_hash' => array('type' => 'varchar', 'precision' => '32', 'nullable' => False), |
|
59 | + 'remote_url' => array('type' => 'varchar', 'precision' => '128', 'nullable' => False), |
|
60 | + 'remote_domain' => array('type' => 'varchar', 'precision' => '64', 'nullable' => False) |
|
61 | 61 | ), |
62 | 62 | 'pk' => array('remote_id'), |
63 | 63 | 'fk' => array(), |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | |
72 | 72 | function admin_upgrade1_5_002() |
73 | 73 | { |
74 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_admin_queue','remote_id',array( |
|
74 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_admin_queue', 'remote_id', array( |
|
75 | 75 | 'type' => 'int', |
76 | 76 | 'precision' => '4' |
77 | 77 | )); |
@@ -110,18 +110,18 @@ discard block |
||
110 | 110 | |
111 | 111 | function admin_upgrade14_1() |
112 | 112 | { |
113 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_admin_queue','cmd_uid',array( |
|
113 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_admin_queue', 'cmd_uid', array( |
|
114 | 114 | 'type' => 'ascii', |
115 | 115 | 'precision' => '64', |
116 | 116 | 'nullable' => False |
117 | 117 | )); |
118 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_admin_queue','cmd_type',array( |
|
118 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_admin_queue', 'cmd_type', array( |
|
119 | 119 | 'type' => 'ascii', |
120 | 120 | 'precision' => '32', |
121 | 121 | 'nullable' => False, |
122 | 122 | 'default' => 'admin_cmd' |
123 | 123 | )); |
124 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_admin_queue','cmd_data',array( |
|
124 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_admin_queue', 'cmd_data', array( |
|
125 | 125 | 'type' => 'ascii', |
126 | 126 | 'precision' => '16384' |
127 | 127 | )); |
@@ -132,17 +132,17 @@ discard block |
||
132 | 132 | |
133 | 133 | function admin_upgrade14_2_001() |
134 | 134 | { |
135 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_admin_remote','remote_hash',array( |
|
135 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_admin_remote', 'remote_hash', array( |
|
136 | 136 | 'type' => 'ascii', |
137 | 137 | 'precision' => '32', |
138 | 138 | 'nullable' => False |
139 | 139 | )); |
140 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_admin_remote','remote_url',array( |
|
140 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_admin_remote', 'remote_url', array( |
|
141 | 141 | 'type' => 'ascii', |
142 | 142 | 'precision' => '128', |
143 | 143 | 'nullable' => False |
144 | 144 | )); |
145 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_admin_remote','remote_domain',array( |
|
145 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_admin_remote', 'remote_domain', array( |
|
146 | 146 | 'type' => 'ascii', |
147 | 147 | 'precision' => '64', |
148 | 148 | 'nullable' => False |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | // asuming everythings not MySQL uses PostgreSQL regular expression syntax |
162 | 162 | $regexp = substr($GLOBALS['egw_setup']->db->Type, 0, 5) == 'mysql' ? 'REGEXP' : '~*'; |
163 | 163 | |
164 | - foreach($GLOBALS['egw_setup']->db->select('egw_admin_queue', 'cmd_id,cmd_data', |
|
164 | + foreach ($GLOBALS['egw_setup']->db->select('egw_admin_queue', 'cmd_id,cmd_data', |
|
165 | 165 | 'cmd_status NOT IN ('.implode(',', admin_cmd::$require_pw_stati).") AND cmd_data $regexp '(pw|passwd\\_?\\d*|password|db\\_pass)\\?\"'", |
166 | 166 | __LINE__, __FILE__, false, '', 'admin') as $row) |
167 | 167 | { |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * @param string $password =null password |
26 | 26 | * @param boolean $run_addaccount_hook =null default run addaccount for new Api\Accounts and editaccount for existing ones |
27 | 27 | */ |
28 | - function __construct($account,$set=null,$password=null,$run_addaccount_hook=null) |
|
28 | + function __construct($account, $set = null, $password = null, $run_addaccount_hook = null) |
|
29 | 29 | { |
30 | 30 | if (!is_array($account)) |
31 | 31 | { |
@@ -49,10 +49,10 @@ discard block |
||
49 | 49 | * @throws Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!",$this->account),15); |
50 | 50 | * @throws Api\Exception\WrongUserinput(lang('Error changing the password for %1 !!!',$this->account),99); |
51 | 51 | */ |
52 | - protected function exec($check_only=false) |
|
52 | + protected function exec($check_only = false) |
|
53 | 53 | { |
54 | 54 | // check creator is still admin and not explicitly forbidden to edit accounts/groups |
55 | - if ($this->creator) $this->_check_admin('account_access',$this->account ? 16 : 4); |
|
55 | + if ($this->creator) $this->_check_admin('account_access', $this->account ? 16 : 4); |
|
56 | 56 | |
57 | 57 | admin_cmd::_instanciate_accounts(); |
58 | 58 | |
@@ -68,29 +68,29 @@ discard block |
||
68 | 68 | } |
69 | 69 | if (!$data['account_lid'] && (!$this->account || !is_null($data['account_lid']))) |
70 | 70 | { |
71 | - throw new Api\Exception\WrongUserinput(lang('You must enter a loginid'),9); |
|
71 | + throw new Api\Exception\WrongUserinput(lang('You must enter a loginid'), 9); |
|
72 | 72 | } |
73 | 73 | // Check if an account already exists as system user, and if it does deny creation |
74 | 74 | if ($GLOBALS['egw_info']['server']['account_repository'] == 'ldap' && |
75 | 75 | !$GLOBALS['egw_info']['server']['ldap_allow_systemusernames'] && !$data['account_id'] && |
76 | 76 | function_exists('posix_getpwnam') && posix_getpwnam($data['account_lid'])) |
77 | 77 | { |
78 | - throw new Api\Exception\WrongUserinput(lang('There already is a system-user with this name. User\'s should not have the same name as a systemuser'),99); |
|
78 | + throw new Api\Exception\WrongUserinput(lang('There already is a system-user with this name. User\'s should not have the same name as a systemuser'), 99); |
|
79 | 79 | } |
80 | 80 | if (!$data['account_lastname'] && (!$this->account || !is_null($data['account_lastname']))) |
81 | 81 | { |
82 | - throw new Api\Exception\WrongUserinput(lang('You must enter a lastname'),9); |
|
82 | + throw new Api\Exception\WrongUserinput(lang('You must enter a lastname'), 9); |
|
83 | 83 | } |
84 | - if (!is_null($data['account_lid']) && ($id = admin_cmd::$accounts->name2id($data['account_lid'],'account_lid','u')) && |
|
84 | + if (!is_null($data['account_lid']) && ($id = admin_cmd::$accounts->name2id($data['account_lid'], 'account_lid', 'u')) && |
|
85 | 85 | (string)$id !== (string)$data['account_id']) |
86 | 86 | { |
87 | - throw new Api\Exception\WrongUserinput(lang('That loginid has already been taken'),999); |
|
87 | + throw new Api\Exception\WrongUserinput(lang('That loginid has already been taken'), 999); |
|
88 | 88 | } |
89 | 89 | if (isset($data['account_passwd_2']) && $data['account_passwd'] != $data['account_passwd_2']) |
90 | 90 | { |
91 | - throw new Api\Exception\WrongUserinput(lang('The two passwords are not the same'),0); |
|
91 | + throw new Api\Exception\WrongUserinput(lang('The two passwords are not the same'), 0); |
|
92 | 92 | } |
93 | - $expires = self::_parse_expired($data['account_expires'],(boolean)$this->account); |
|
93 | + $expires = self::_parse_expired($data['account_expires'], (boolean)$this->account); |
|
94 | 94 | if ($expires === 0) // deactivated |
95 | 95 | { |
96 | 96 | $data['account_expires'] = -1; |
@@ -102,16 +102,16 @@ discard block |
||
102 | 102 | $data['account_status'] = is_null($expires) ? null : ($expires == -1 || $expires > time() ? 'A' : ''); |
103 | 103 | } |
104 | 104 | |
105 | - $data['changepassword'] = admin_cmd::parse_boolean($data['changepassword'],$this->account ? null : true); |
|
106 | - $data['anonymous'] = admin_cmd::parse_boolean($data['anonymous'],$this->account ? null : false); |
|
105 | + $data['changepassword'] = admin_cmd::parse_boolean($data['changepassword'], $this->account ? null : true); |
|
106 | + $data['anonymous'] = admin_cmd::parse_boolean($data['anonymous'], $this->account ? null : false); |
|
107 | 107 | if ($data['mustchangepassword'] && $data['changepassword']) |
108 | 108 | { |
109 | - $data['account_lastpwd_change']=0; |
|
109 | + $data['account_lastpwd_change'] = 0; |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | if (!$data['account_primary_group'] && $this->account) |
113 | 113 | { |
114 | - $data['account_primary_group'] = null; // dont change |
|
114 | + $data['account_primary_group'] = null; // dont change |
|
115 | 115 | } |
116 | 116 | else |
117 | 117 | { |
@@ -119,11 +119,11 @@ discard block |
||
119 | 119 | { |
120 | 120 | $data['account_primary_group'] = 'Default'; |
121 | 121 | } |
122 | - $data['account_primary_group'] = admin_cmd::parse_account($data['account_primary_group'],false); |
|
122 | + $data['account_primary_group'] = admin_cmd::parse_account($data['account_primary_group'], false); |
|
123 | 123 | } |
124 | 124 | if (!$data['account_groups'] && $this->account) |
125 | 125 | { |
126 | - $data['account_groups'] = null; // dont change |
|
126 | + $data['account_groups'] = null; // dont change |
|
127 | 127 | } |
128 | 128 | else |
129 | 129 | { |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | { |
132 | 132 | $data['account_groups'] = array('Default'); |
133 | 133 | } |
134 | - $data['account_groups'] = admin_cmd::parse_accounts($data['account_groups'],false); |
|
134 | + $data['account_groups'] = admin_cmd::parse_accounts($data['account_groups'], false); |
|
135 | 135 | } |
136 | 136 | if ($check_only) return true; |
137 | 137 | |
@@ -141,27 +141,27 @@ discard block |
||
141 | 141 | Api\Accounts::cache_invalidate($data['account_id']); |
142 | 142 | if (!($old = admin_cmd::$accounts->read($data['account_id']))) |
143 | 143 | { |
144 | - throw new Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!",$this->account),15); |
|
144 | + throw new Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!", $this->account), 15); |
|
145 | 145 | } |
146 | 146 | // as the current account class always sets all values, we have to add the not specified ones |
147 | - foreach($data as $name => &$value) |
|
147 | + foreach ($data as $name => &$value) |
|
148 | 148 | { |
149 | 149 | if (is_null($value)) $value = $old[$name]; |
150 | 150 | } |
151 | 151 | } |
152 | 152 | else |
153 | 153 | { |
154 | - unset($data['account_id']); // otherwise add will fail under postgres |
|
154 | + unset($data['account_id']); // otherwise add will fail under postgres |
|
155 | 155 | } |
156 | 156 | // hook allowing apps to intercept adding/editing Api\Accounts before saving them |
157 | - Api\Hooks::process($data+array( |
|
157 | + Api\Hooks::process($data + array( |
|
158 | 158 | 'location' => $this->account ? 'pre_editaccount' : 'pre_addaccount', |
159 | - ),False,True); // called for every app now, not only enabled ones) |
|
159 | + ), False, True); // called for every app now, not only enabled ones) |
|
160 | 160 | |
161 | 161 | if (!($data['account_id'] = admin_cmd::$accounts->save($data))) |
162 | 162 | { |
163 | 163 | //_debug_array($data); |
164 | - throw new Api\Db\Exception(lang("Error saving account!"),11); |
|
164 | + throw new Api\Db\Exception(lang("Error saving account!"), 11); |
|
165 | 165 | } |
166 | 166 | // make new account_id available to caller |
167 | 167 | $update = (boolean)$this->account; |
@@ -169,44 +169,44 @@ discard block |
||
169 | 169 | |
170 | 170 | if ($data['account_groups']) |
171 | 171 | { |
172 | - admin_cmd::$accounts->set_memberships($data['account_groups'],$data['account_id']); |
|
172 | + admin_cmd::$accounts->set_memberships($data['account_groups'], $data['account_id']); |
|
173 | 173 | } |
174 | 174 | if (!is_null($data['anonymous'])) |
175 | 175 | { |
176 | 176 | admin_cmd::_instanciate_acl(); |
177 | 177 | if ($data['anonymous']) |
178 | 178 | { |
179 | - admin_cmd::$acl->add_repository('phpgwapi','anonymous',$data['account_id'],1); |
|
179 | + admin_cmd::$acl->add_repository('phpgwapi', 'anonymous', $data['account_id'], 1); |
|
180 | 180 | } |
181 | 181 | else |
182 | 182 | { |
183 | - admin_cmd::$acl->delete_repository('phpgwapi','anonymous',$data['account_id']); |
|
183 | + admin_cmd::$acl->delete_repository('phpgwapi', 'anonymous', $data['account_id']); |
|
184 | 184 | } |
185 | 185 | } |
186 | 186 | if (!is_null($data['changepassword'])) |
187 | 187 | { |
188 | 188 | if (!$data['changepassword']) |
189 | 189 | { |
190 | - admin_cmd::$acl->add_repository('preferences','nopasswordchange',$data['account_id'],1); |
|
190 | + admin_cmd::$acl->add_repository('preferences', 'nopasswordchange', $data['account_id'], 1); |
|
191 | 191 | } |
192 | 192 | else |
193 | 193 | { |
194 | - admin_cmd::$acl->delete_repository('preferences','nopasswordchange',$data['account_id']); |
|
194 | + admin_cmd::$acl->delete_repository('preferences', 'nopasswordchange', $data['account_id']); |
|
195 | 195 | } |
196 | 196 | } |
197 | 197 | // if we have a password and it's not a hash, and auth_type != account_repository |
198 | 198 | if (!is_null($this->password) && |
199 | - !preg_match('/^\\{[a-z5]{3,5}\\}.+/i',$this->password) && |
|
200 | - !preg_match('/^[0-9a-f]{32}$/',$this->password) && // md5 hash |
|
199 | + !preg_match('/^\\{[a-z5]{3,5}\\}.+/i', $this->password) && |
|
200 | + !preg_match('/^[0-9a-f]{32}$/', $this->password) && // md5 hash |
|
201 | 201 | admin_cmd::$accounts->config['auth_type'] != admin_cmd::$accounts->config['account_repository']) |
202 | 202 | { |
203 | - admin_cmd_change_pw::exec(); // calling the exec method of the admin_cmd_change_pw |
|
203 | + admin_cmd_change_pw::exec(); // calling the exec method of the admin_cmd_change_pw |
|
204 | 204 | } |
205 | 205 | $data['account_passwd'] = $this->password; |
206 | - $GLOBALS['hook_values'] =& $data; |
|
207 | - Api\Hooks::process($GLOBALS['hook_values']+array( |
|
206 | + $GLOBALS['hook_values'] = & $data; |
|
207 | + Api\Hooks::process($GLOBALS['hook_values'] + array( |
|
208 | 208 | 'location' => $update && $this->run_addaccount_hook !== true ? 'editaccount' : 'addaccount' |
209 | - ),False,True); // called for every app now, not only enabled ones) |
|
209 | + ), False, True); // called for every app now, not only enabled ones) |
|
210 | 210 | |
211 | 211 | return lang("Account %1 %2", $data['account_lid'] ? $data['account_lid'] : Api\Accounts::id2name($this->account), |
212 | 212 | $update ? lang('updated') : lang("created with id #%1", $this->account)); |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | */ |
220 | 220 | function __tostring() |
221 | 221 | { |
222 | - return lang('%1 user %2',$this->account ? lang('Edit') : lang('Add'), |
|
222 | + return lang('%1 user %2', $this->account ? lang('Edit') : lang('Add'), |
|
223 | 223 | admin_cmd::display_account($this->account ? $this->account : $this->set['account_lid'])); |
224 | 224 | } |
225 | 225 | |
@@ -231,9 +231,9 @@ discard block |
||
231 | 231 | * @return int timestamp, 0 for already, -1 for never or null for dont change |
232 | 232 | * @throws Api\Exception\WrongUserinput(lang('Invalid formated date "%1"!',$datein),6); |
233 | 233 | */ |
234 | - private function _parse_expired($str,$existing) |
|
234 | + private function _parse_expired($str, $existing) |
|
235 | 235 | { |
236 | - switch($str) |
|
236 | + switch ($str) |
|
237 | 237 | { |
238 | 238 | case '': |
239 | 239 | if ($existing) return null; |
@@ -52,16 +52,22 @@ discard block |
||
52 | 52 | protected function exec($check_only=false) |
53 | 53 | { |
54 | 54 | // check creator is still admin and not explicitly forbidden to edit accounts/groups |
55 | - if ($this->creator) $this->_check_admin('account_access',$this->account ? 16 : 4); |
|
55 | + if ($this->creator) |
|
56 | + { |
|
57 | + $this->_check_admin('account_access',$this->account ? 16 : 4); |
|
58 | + } |
|
56 | 59 | |
57 | 60 | admin_cmd::_instanciate_accounts(); |
58 | 61 | |
59 | 62 | $data = $this->set; |
60 | 63 | $data['account_type'] = 'u'; |
61 | 64 | |
62 | - if ($this->account) // existing account |
|
65 | + if ($this->account) |
|
66 | + { |
|
67 | + // existing account |
|
63 | 68 | { |
64 | 69 | $data['account_id'] = admin_cmd::parse_account($this->account); |
70 | + } |
|
65 | 71 | //error_log(__METHOD__."($check_only) this->account=".array2string($this->account).', data[account_id]='.array2string($data['account_id']).", ...)"); |
66 | 72 | |
67 | 73 | $data['old_loginid'] = admin_cmd::$accounts->id2name($data['account_id']); |
@@ -91,9 +97,12 @@ discard block |
||
91 | 97 | throw new Api\Exception\WrongUserinput(lang('The two passwords are not the same'),0); |
92 | 98 | } |
93 | 99 | $expires = self::_parse_expired($data['account_expires'],(boolean)$this->account); |
94 | - if ($expires === 0) // deactivated |
|
100 | + if ($expires === 0) |
|
101 | + { |
|
102 | + // deactivated |
|
95 | 103 | { |
96 | 104 | $data['account_expires'] = -1; |
105 | + } |
|
97 | 106 | $data['account_status'] = ''; |
98 | 107 | } |
99 | 108 | else |
@@ -133,7 +142,10 @@ discard block |
||
133 | 142 | } |
134 | 143 | $data['account_groups'] = admin_cmd::parse_accounts($data['account_groups'],false); |
135 | 144 | } |
136 | - if ($check_only) return true; |
|
145 | + if ($check_only) |
|
146 | + { |
|
147 | + return true; |
|
148 | + } |
|
137 | 149 | |
138 | 150 | if ($this->account) |
139 | 151 | { |
@@ -146,7 +158,10 @@ discard block |
||
146 | 158 | // as the current account class always sets all values, we have to add the not specified ones |
147 | 159 | foreach($data as $name => &$value) |
148 | 160 | { |
149 | - if (is_null($value)) $value = $old[$name]; |
|
161 | + if (is_null($value)) |
|
162 | + { |
|
163 | + $value = $old[$name]; |
|
164 | + } |
|
150 | 165 | } |
151 | 166 | } |
152 | 167 | else |
@@ -165,7 +180,10 @@ discard block |
||
165 | 180 | } |
166 | 181 | // make new account_id available to caller |
167 | 182 | $update = (boolean)$this->account; |
168 | - if (!$this->account) $this->account = $data['account_id']; |
|
183 | + if (!$this->account) |
|
184 | + { |
|
185 | + $this->account = $data['account_id']; |
|
186 | + } |
|
169 | 187 | |
170 | 188 | if ($data['account_groups']) |
171 | 189 | { |
@@ -236,7 +254,10 @@ discard block |
||
236 | 254 | switch($str) |
237 | 255 | { |
238 | 256 | case '': |
239 | - if ($existing) return null; |
|
257 | + if ($existing) |
|
258 | + { |
|
259 | + return null; |
|
260 | + } |
|
240 | 261 | // fall through --> default for new Api\Accounts is never |
241 | 262 | case 'never': |
242 | 263 | return -1; |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | { |
21 | 21 | var $public_functions = array('index' => True); |
22 | 22 | |
23 | - function index($params=null) |
|
23 | + function index($params = null) |
|
24 | 24 | { |
25 | 25 | // if we have a xet file, run new et2 config |
26 | 26 | if (file_exists(EGW_SERVER_ROOT.'/'.$_GET['appname'].'/templates/default/config.xet')) |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | //_debug_array($params); |
47 | 47 | $_appname = $_GET['appname']; |
48 | 48 | } |
49 | - if ($GLOBALS['egw']->acl->check('site_config_acce',1,'admin')) |
|
49 | + if ($GLOBALS['egw']->acl->check('site_config_acce', 1, 'admin')) |
|
50 | 50 | { |
51 | 51 | Egw::redirect_link('/index.php'); |
52 | 52 | } |
@@ -57,12 +57,12 @@ discard block |
||
57 | 57 | Api\Translation::add_app($_appname); |
58 | 58 | } |
59 | 59 | |
60 | - if(get_magic_quotes_gpc() && is_array($_POST['newsettings'])) |
|
60 | + if (get_magic_quotes_gpc() && is_array($_POST['newsettings'])) |
|
61 | 61 | { |
62 | 62 | $_POST['newsettings'] = array_stripslashes($_POST['newsettings']); |
63 | 63 | } |
64 | 64 | |
65 | - switch($_appname) |
|
65 | + switch ($_appname) |
|
66 | 66 | { |
67 | 67 | case 'admin': |
68 | 68 | case 'addressbook': |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | $t = new Framework\Template(Framework\Template::get_dir($appname)); |
90 | 90 | $t->set_unknowns('keep'); |
91 | 91 | $t->set_file(array('config' => 'config.tpl')); |
92 | - $t->set_block('config','header','header'); |
|
92 | + $t->set_block('config', 'header', 'header'); |
|
93 | 93 | |
94 | 94 | // fix header templates missing essential parts like display of validation errors |
95 | 95 | $header = $t->get_var('header'); |
@@ -107,15 +107,15 @@ discard block |
||
107 | 107 | } |
108 | 108 | $t->set_var('header', $header); |
109 | 109 | |
110 | - $t->set_block('config','body','body'); |
|
111 | - $t->set_block('config','footer','footer'); |
|
110 | + $t->set_block('config', 'body', 'body'); |
|
111 | + $t->set_block('config', 'footer', 'footer'); |
|
112 | 112 | |
113 | 113 | // fix footer submit buttons to just {submit} {cancel} |
114 | 114 | $t->set_var('footer', preg_replace('/<input[^>]+value="{lang_(submit|cancel)}"[^>]*>/', '{$1}', $t->get_var('footer'))); |
115 | 115 | |
116 | 116 | $c = new Api\Config($config_appname); |
117 | 117 | $c->read_repository(); |
118 | - if ($_POST['cancel'] || ($_POST['submit'] || $_POST['save'] || $_POST['apply']) && $GLOBALS['egw']->acl->check('site_config_acce',2,'admin')) |
|
118 | + if ($_POST['cancel'] || ($_POST['submit'] || $_POST['save'] || $_POST['apply']) && $GLOBALS['egw']->acl->check('site_config_acce', 2, 'admin')) |
|
119 | 119 | { |
120 | 120 | Egw::redirect_link('/admin/index.php?ajax=true'); |
121 | 121 | } |
@@ -123,9 +123,9 @@ discard block |
||
123 | 123 | if ($_POST['submit'] || $_POST['save'] || $_POST['apply']) |
124 | 124 | { |
125 | 125 | /* Load hook file with functions to validate each Api\Config (one/none/all) */ |
126 | - Api\Hooks::single('config_validate',$appname); |
|
126 | + Api\Hooks::single('config_validate', $appname); |
|
127 | 127 | |
128 | - foreach($_POST['newsettings'] as $key => $config) |
|
128 | + foreach ($_POST['newsettings'] as $key => $config) |
|
129 | 129 | { |
130 | 130 | if ($config) |
131 | 131 | { |
@@ -133,26 +133,26 @@ discard block |
||
133 | 133 | if (in_array($key, (array)$GLOBALS['egw_info']['server']['found_validation_hook'], true) && function_exists($key)) |
134 | 134 | { |
135 | 135 | call_user_func($key, $config, $c); |
136 | - if($GLOBALS['config_error']) |
|
136 | + if ($GLOBALS['config_error']) |
|
137 | 137 | { |
138 | - $errors .= lang($GLOBALS['config_error']) . "\n"; |
|
138 | + $errors .= lang($GLOBALS['config_error'])."\n"; |
|
139 | 139 | $GLOBALS['config_error'] = False; |
140 | 140 | } |
141 | 141 | } |
142 | 142 | } |
143 | 143 | /* don't erase passwords, since we also don't print them */ |
144 | - elseif(strpos($key,'passwd') === false && strpos($key,'password') === false && strpos($key,'root_pw') === false) |
|
144 | + elseif (strpos($key, 'passwd') === false && strpos($key, 'password') === false && strpos($key, 'root_pw') === false) |
|
145 | 145 | { |
146 | 146 | unset($c->config_data[$key]); |
147 | 147 | } |
148 | 148 | } |
149 | - if(in_array('final_validation', (array)$GLOBALS['egw_info']['server']['found_validation_hook']) && |
|
149 | + if (in_array('final_validation', (array)$GLOBALS['egw_info']['server']['found_validation_hook']) && |
|
150 | 150 | function_exists('final_validation')) |
151 | 151 | { |
152 | 152 | final_validation($_POST['newsettings']); |
153 | - if($GLOBALS['config_error']) |
|
153 | + if ($GLOBALS['config_error']) |
|
154 | 154 | { |
155 | - $errors .= lang($GLOBALS['config_error']) . "\n"; |
|
155 | + $errors .= lang($GLOBALS['config_error'])."\n"; |
|
156 | 156 | $GLOBALS['config_error'] = False; |
157 | 157 | } |
158 | 158 | unset($GLOBALS['egw_info']['server']['found_validation_hook']); |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | |
161 | 161 | $c->save_repository(); |
162 | 162 | |
163 | - if(!$errors && !$_POST['apply']) |
|
163 | + if (!$errors && !$_POST['apply']) |
|
164 | 164 | { |
165 | 165 | Framework::message(lang('Configuration saved.'), 'success'); |
166 | 166 | Egw::redirect_link('/index.php', array( |
@@ -170,10 +170,10 @@ discard block |
||
170 | 170 | } |
171 | 171 | } |
172 | 172 | |
173 | - $t->set_var('error',''); |
|
174 | - if($errors) |
|
173 | + $t->set_var('error', ''); |
|
174 | + if ($errors) |
|
175 | 175 | { |
176 | - Framework::message(lang('Error') . ': ' . $errors, 'error'); |
|
176 | + Framework::message(lang('Error').': '.$errors, 'error'); |
|
177 | 177 | unset($errors); |
178 | 178 | unset($GLOBALS['config_error']); |
179 | 179 | } |
@@ -181,41 +181,41 @@ discard block |
||
181 | 181 | { |
182 | 182 | Framework::message(lang('Configuration saved.'), 'success'); |
183 | 183 | } |
184 | - $t->set_var('title',lang('Site Configuration')); |
|
185 | - $t->set_var('action_url',$GLOBALS['egw']->link('/index.php','menuaction=admin.uiconfig.index&appname=' . $appname)); |
|
186 | - $t->set_var('th_bg', $GLOBALS['egw_info']['theme']['th_bg']); |
|
187 | - $t->set_var('th_text', $GLOBALS['egw_info']['theme']['th_text']); |
|
188 | - $t->set_var('row_on', $GLOBALS['egw_info']['theme']['row_on']); |
|
189 | - $t->set_var('row_off', $GLOBALS['egw_info']['theme']['row_off']); |
|
184 | + $t->set_var('title', lang('Site Configuration')); |
|
185 | + $t->set_var('action_url', $GLOBALS['egw']->link('/index.php', 'menuaction=admin.uiconfig.index&appname='.$appname)); |
|
186 | + $t->set_var('th_bg', $GLOBALS['egw_info']['theme']['th_bg']); |
|
187 | + $t->set_var('th_text', $GLOBALS['egw_info']['theme']['th_text']); |
|
188 | + $t->set_var('row_on', $GLOBALS['egw_info']['theme']['row_on']); |
|
189 | + $t->set_var('row_off', $GLOBALS['egw_info']['theme']['row_off']); |
|
190 | 190 | $t->set_var('hidden_vars', Api\Html::input_hidden('csrf_token', Api\Csrf::token(__CLASS__))); |
191 | 191 | |
192 | 192 | $vars = $t->get_undefined('body'); |
193 | 193 | |
194 | - if (Api\Hooks::single('config',$appname)) // reload the config-values, they might have changed |
|
194 | + if (Api\Hooks::single('config', $appname)) // reload the config-values, they might have changed |
|
195 | 195 | { |
196 | 196 | $c->read_repository(); |
197 | 197 | } |
198 | - foreach($vars as $value) |
|
198 | + foreach ($vars as $value) |
|
199 | 199 | { |
200 | - $valarray = explode('_',$value); |
|
200 | + $valarray = explode('_', $value); |
|
201 | 201 | $type = array_shift($valarray); |
202 | - $newval = implode(' ',$valarray); |
|
202 | + $newval = implode(' ', $valarray); |
|
203 | 203 | |
204 | 204 | switch ($type) |
205 | 205 | { |
206 | 206 | case 'lang': |
207 | - $t->set_var($value,lang($newval)); |
|
207 | + $t->set_var($value, lang($newval)); |
|
208 | 208 | break; |
209 | 209 | case 'value': |
210 | - $newval = str_replace(' ','_',$newval); |
|
210 | + $newval = str_replace(' ', '_', $newval); |
|
211 | 211 | /* Don't show passwords in the form */ |
212 | - if(strpos($value,'passwd') !== false || strpos($value,'password') !== false || strpos($value,'root_pw') !== false) |
|
212 | + if (strpos($value, 'passwd') !== false || strpos($value, 'password') !== false || strpos($value, 'root_pw') !== false) |
|
213 | 213 | { |
214 | - $t->set_var($value,''); |
|
214 | + $t->set_var($value, ''); |
|
215 | 215 | } |
216 | 216 | else |
217 | 217 | { |
218 | - $t->set_var($value,$c->config_data[$newval]); |
|
218 | + $t->set_var($value, $c->config_data[$newval]); |
|
219 | 219 | } |
220 | 220 | break; |
221 | 221 | /* |
@@ -233,46 +233,45 @@ discard block |
||
233 | 233 | */ |
234 | 234 | case 'selected': |
235 | 235 | $configs = array(); |
236 | - $newvals = explode(' ',$newval); |
|
236 | + $newvals = explode(' ', $newval); |
|
237 | 237 | $setting = end($newvals); |
238 | - for ($i=0;$i<(count($newvals) - 1); $i++) |
|
238 | + for ($i = 0; $i < (count($newvals) - 1); $i++) |
|
239 | 239 | { |
240 | 240 | $configs[] = $newvals[$i]; |
241 | 241 | } |
242 | - $config = implode('_',$configs); |
|
242 | + $config = implode('_', $configs); |
|
243 | 243 | /* echo $config . '=' . $c->config_data[$config]; */ |
244 | 244 | if ($c->config_data[$config] == $setting) |
245 | 245 | { |
246 | - $t->set_var($value,' selected'); |
|
246 | + $t->set_var($value, ' selected'); |
|
247 | 247 | } |
248 | 248 | else |
249 | 249 | { |
250 | - $t->set_var($value,''); |
|
250 | + $t->set_var($value, ''); |
|
251 | 251 | } |
252 | 252 | break; |
253 | 253 | case 'hook': |
254 | - $newval = str_replace(' ','_',$newval); |
|
255 | - if(function_exists($newval)) |
|
254 | + $newval = str_replace(' ', '_', $newval); |
|
255 | + if (function_exists($newval)) |
|
256 | 256 | { |
257 | - $t->set_var($value,$newval($c->config_data)); |
|
257 | + $t->set_var($value, $newval($c->config_data)); |
|
258 | 258 | } |
259 | 259 | else |
260 | 260 | { |
261 | - $t->set_var($value,''); |
|
261 | + $t->set_var($value, ''); |
|
262 | 262 | } |
263 | 263 | break; |
264 | 264 | case 'call': // eg. call_class::method or call_app.class.method |
265 | - $newval = str_replace(' ','_',$newval); |
|
266 | - $t->set_var($value,ExecMethod($newval,$c->config_data)); |
|
265 | + $newval = str_replace(' ', '_', $newval); |
|
266 | + $t->set_var($value, ExecMethod($newval, $c->config_data)); |
|
267 | 267 | break; |
268 | 268 | default: |
269 | - $t->set_var($value,''); |
|
269 | + $t->set_var($value, ''); |
|
270 | 270 | break; |
271 | 271 | } |
272 | 272 | } |
273 | 273 | $t->set_var('submit', '<div class="dialogFooterToolbar" style="text-align: left">'. |
274 | - ($GLOBALS['egw']->acl->check('site_config_acce',2,'admin') ? '' : |
|
275 | - Api\Html::submit_button('save', 'Save')."\n". |
|
274 | + ($GLOBALS['egw']->acl->check('site_config_acce', 2, 'admin') ? '' : Api\Html::submit_button('save', 'Save')."\n". |
|
276 | 275 | Api\Html::submit_button('apply', 'Apply'))); |
277 | 276 | $t->set_var('cancel', Api\Html::submit_button('cancel', 'Cancel').'</div>'); |
278 | 277 | |
@@ -282,10 +281,10 @@ discard block |
||
282 | 281 | // render the page |
283 | 282 | $GLOBALS['egw']->framework->render( |
284 | 283 | '<div id="admin-config-'.$appname.'" class="admin-config">'. |
285 | - $t->parse('out','header'). |
|
286 | - $t->fp('out','body'). |
|
287 | - $t->fp('out','footer').'</div>', |
|
288 | - null,true |
|
284 | + $t->parse('out', 'header'). |
|
285 | + $t->fp('out', 'body'). |
|
286 | + $t->fp('out', 'footer').'</div>', |
|
287 | + null, true |
|
289 | 288 | ); |
290 | 289 | } |
291 | 290 | } |
@@ -85,7 +85,11 @@ discard block |
||
85 | 85 | $config_appname = $appname; |
86 | 86 | break; |
87 | 87 | } |
88 | - if (ob_get_contents()) ob_end_flush(); // if there is output in buffer, flush it now. |
|
88 | + if (ob_get_contents()) |
|
89 | + { |
|
90 | + ob_end_flush(); |
|
91 | + } |
|
92 | + // if there is output in buffer, flush it now. |
|
89 | 93 | $t = new Framework\Template(Framework\Template::get_dir($appname)); |
90 | 94 | $t->set_unknowns('keep'); |
91 | 95 | $t->set_file(array('config' => 'config.tpl')); |
@@ -191,10 +195,13 @@ discard block |
||
191 | 195 | |
192 | 196 | $vars = $t->get_undefined('body'); |
193 | 197 | |
194 | - if (Api\Hooks::single('config',$appname)) // reload the config-values, they might have changed |
|
198 | + if (Api\Hooks::single('config',$appname)) |
|
199 | + { |
|
200 | + // reload the config-values, they might have changed |
|
195 | 201 | { |
196 | 202 | $c->read_repository(); |
197 | 203 | } |
204 | + } |
|
198 | 205 | foreach($vars as $value) |
199 | 206 | { |
200 | 207 | $valarray = explode('_',$value); |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * |
21 | 21 | * @param array $data =array() default parm from parent class, no real parameters |
22 | 22 | */ |
23 | - function __construct($data=array()) |
|
23 | + function __construct($data = array()) |
|
24 | 24 | { |
25 | 25 | admin_cmd::__construct($data); |
26 | 26 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @throws Exception(lang("Unknown account: %1 !!!",$this->account),15); |
35 | 35 | * @throws Exception(lang("Application '%1' not found (maybe not installed or misspelled)!",$name),8); |
36 | 36 | */ |
37 | - protected function exec($check_only=false) |
|
37 | + protected function exec($check_only = false) |
|
38 | 38 | { |
39 | 39 | if ($check_only) return true; |
40 | 40 | |
@@ -43,14 +43,14 @@ discard block |
||
43 | 43 | if (($all_accounts = admin_cmd::$accounts->search(array('type'=>'both')))) |
44 | 44 | { |
45 | 45 | $ids = array(); |
46 | - foreach($all_accounts as $account) |
|
46 | + foreach ($all_accounts as $account) |
|
47 | 47 | { |
48 | 48 | $ids[] = $account['account_id']; |
49 | 49 | } |
50 | - $GLOBALS['egw']->db->query("DELETE FROM egw_acl WHERE acl_account NOT IN (".implode(',',$ids).") OR acl_appname='phpgw_group' AND acl_location NOT IN ('".implode("','",$ids)."')",__LINE__,__FILE__); |
|
50 | + $GLOBALS['egw']->db->query("DELETE FROM egw_acl WHERE acl_account NOT IN (".implode(',', $ids).") OR acl_appname='phpgw_group' AND acl_location NOT IN ('".implode("','", $ids)."')", __LINE__, __FILE__); |
|
51 | 51 | $deleted = $GLOBALS['egw']->db->affected_rows(); |
52 | 52 | } |
53 | - return lang("%1 ACL records of not (longer) existing Api\Accounts deleted.",$deleted); |
|
53 | + return lang("%1 ACL records of not (longer) existing Api\Accounts deleted.", $deleted); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -36,7 +36,10 @@ |
||
36 | 36 | */ |
37 | 37 | protected function exec($check_only=false) |
38 | 38 | { |
39 | - if ($check_only) return true; |
|
39 | + if ($check_only) |
|
40 | + { |
|
41 | + return true; |
|
42 | + } |
|
40 | 43 | |
41 | 44 | admin_cmd::_instanciate_accounts(); |
42 | 45 | $deleted = 0; |
@@ -31,25 +31,24 @@ discard block |
||
31 | 31 | * @param array &$readonlys |
32 | 32 | * @return int |
33 | 33 | */ |
34 | - static function get_rows(array $query,&$rows,&$readonlys) |
|
34 | + static function get_rows(array $query, &$rows, &$readonlys) |
|
35 | 35 | { |
36 | 36 | Api\Cache::setSession('admin', 'cmds', $query); |
37 | 37 | |
38 | - $total = admin_cmd::get_rows($query,$rows,$readonlys); |
|
38 | + $total = admin_cmd::get_rows($query, $rows, $readonlys); |
|
39 | 39 | |
40 | 40 | if (!$rows) return array(); |
41 | 41 | |
42 | - foreach($rows as &$row) |
|
42 | + foreach ($rows as &$row) |
|
43 | 43 | { |
44 | 44 | try { |
45 | 45 | $cmd = admin_cmd::instanciate($row); |
46 | - $row['title'] = $cmd->__tostring(); // we call __tostring explicit, as a cast to string requires php5.2+ |
|
46 | + $row['title'] = $cmd->__tostring(); // we call __tostring explicit, as a cast to string requires php5.2+ |
|
47 | 47 | } |
48 | 48 | catch (Exception $e) { |
49 | 49 | $row['title'] = $e->getMessage(); |
50 | 50 | } |
51 | - $row['data'] = !($data = json_php_unserialize($row['data'])) ? '' : |
|
52 | - json_encode($data, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES); |
|
51 | + $row['data'] = !($data = json_php_unserialize($row['data'])) ? '' : json_encode($data, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES); |
|
53 | 52 | |
54 | 53 | if ($row['status'] == admin_cmd::scheduled) |
55 | 54 | { |
@@ -65,7 +64,7 @@ discard block |
||
65 | 64 | * |
66 | 65 | * @param array $content =null |
67 | 66 | */ |
68 | - static function index(array $content=null) |
|
67 | + static function index(array $content = null) |
|
69 | 68 | { |
70 | 69 | $tpl = new Etemplate('admin.cmds'); |
71 | 70 | |
@@ -75,10 +74,10 @@ discard block |
||
75 | 74 | if (!is_array($content['nm'])) |
76 | 75 | { |
77 | 76 | $content['nm'] = array( |
78 | - 'get_rows' => 'admin.admin_cmds.get_rows', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
79 | - 'no_filter' => true, // I disable the 1. filter |
|
80 | - 'no_filter2' => true, // I disable the 2. filter (params are the same as for filter) |
|
81 | - 'no_cat' => true, // I disable the cat-selectbox |
|
77 | + 'get_rows' => 'admin.admin_cmds.get_rows', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
78 | + 'no_filter' => true, // I disable the 1. filter |
|
79 | + 'no_filter2' => true, // I disable the 2. filter (params are the same as for filter) |
|
80 | + 'no_cat' => true, // I disable the cat-selectbox |
|
82 | 81 | 'order' => 'cmd_created', |
83 | 82 | 'sort' => 'DESC', |
84 | 83 | 'row_id' => 'id', |
@@ -98,10 +97,10 @@ discard block |
||
98 | 97 | } |
99 | 98 | unset($cmd); |
100 | 99 | } |
101 | - $tpl->exec('admin.admin_cmds.index',$content,array( |
|
100 | + $tpl->exec('admin.admin_cmds.index', $content, array( |
|
102 | 101 | 'status' => admin_cmd::$stati, |
103 | 102 | 'remote_id' => admin_cmd::remote_sites(), |
104 | - ),array(),$content); |
|
103 | + ), array(), $content); |
|
105 | 104 | } |
106 | 105 | |
107 | 106 | /** |
@@ -127,9 +126,9 @@ discard block |
||
127 | 126 | * @param array &$readonlys |
128 | 127 | * @return int |
129 | 128 | */ |
130 | - static function get_remotes(array $query,&$rows,&$readonlys) |
|
129 | + static function get_remotes(array $query, &$rows, &$readonlys) |
|
131 | 130 | { |
132 | - return admin_cmd::get_remotes($query,$rows,$readonlys); |
|
131 | + return admin_cmd::get_remotes($query, $rows, $readonlys); |
|
133 | 132 | } |
134 | 133 | |
135 | 134 | /** |
@@ -137,7 +136,7 @@ discard block |
||
137 | 136 | * |
138 | 137 | * @param array $content =null |
139 | 138 | */ |
140 | - static function remotes(array $content=null) |
|
139 | + static function remotes(array $content = null) |
|
141 | 140 | { |
142 | 141 | $tpl = new Etemplate('admin.remotes'); |
143 | 142 | |
@@ -147,10 +146,10 @@ discard block |
||
147 | 146 | if (!is_array($content['nm'])) |
148 | 147 | { |
149 | 148 | $content['nm'] = array( |
150 | - 'get_rows' => 'admin.admin_cmds.get_remotes', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
151 | - 'no_filter' => true, // I disable the 1. filter |
|
152 | - 'no_filter2' => true, // I disable the 2. filter (params are the same as for filter) |
|
153 | - 'no_cat' => true, // I disable the cat-selectbox |
|
149 | + 'get_rows' => 'admin.admin_cmds.get_remotes', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
150 | + 'no_filter' => true, // I disable the 1. filter |
|
151 | + 'no_filter2' => true, // I disable the 2. filter (params are the same as for filter) |
|
152 | + 'no_cat' => true, // I disable the cat-selectbox |
|
154 | 153 | 'order' => 'remote_name', |
155 | 154 | 'sort' => 'ASC', |
156 | 155 | 'row_id' => 'remote_id', |
@@ -165,7 +164,7 @@ discard block |
||
165 | 164 | |
166 | 165 | if ($content['nm']['action']) |
167 | 166 | { |
168 | - switch($content['nm']['action']) |
|
167 | + switch ($content['nm']['action']) |
|
169 | 168 | { |
170 | 169 | case 'edit': |
171 | 170 | $content['remote'] = admin_cmd::read_remote($content['nm']['selected'][0]); |
@@ -175,11 +174,11 @@ discard block |
||
175 | 174 | } |
176 | 175 | unset($content['nm']['action']); |
177 | 176 | } |
178 | - elseif($content['remote']['button']) |
|
177 | + elseif ($content['remote']['button']) |
|
179 | 178 | { |
180 | 179 | list($button) = each($content['remote']['button']); |
181 | 180 | unset($content['remote']['button']); |
182 | - switch($button) |
|
181 | + switch ($button) |
|
183 | 182 | { |
184 | 183 | case 'save': |
185 | 184 | case 'apply': |
@@ -210,7 +209,7 @@ discard block |
||
210 | 209 | unset($content['nm']['add']); |
211 | 210 | } |
212 | 211 | } |
213 | - $tpl->exec('admin.admin_cmds.remotes',$content,array(),array(),$content); |
|
212 | + $tpl->exec('admin.admin_cmds.remotes', $content, array(), array(), $content); |
|
214 | 213 | } |
215 | 214 | |
216 | 215 | /** |
@@ -226,7 +225,7 @@ discard block |
||
226 | 225 | 'default' => true, |
227 | 226 | 'allowOnMultiple' => false, |
228 | 227 | 'nm_action' => 'submit', |
229 | - 'group' => $group=0, |
|
228 | + 'group' => $group = 0, |
|
230 | 229 | ), |
231 | 230 | 'add' => array( |
232 | 231 | 'caption' => 'Add', |
@@ -37,7 +37,10 @@ discard block |
||
37 | 37 | |
38 | 38 | $total = admin_cmd::get_rows($query,$rows,$readonlys); |
39 | 39 | |
40 | - if (!$rows) return array(); |
|
40 | + if (!$rows) |
|
41 | + { |
|
42 | + return array(); |
|
43 | + } |
|
41 | 44 | |
42 | 45 | foreach($rows as &$row) |
43 | 46 | { |
@@ -193,11 +196,15 @@ discard block |
||
193 | 196 | try { |
194 | 197 | $content['remote']['remote_id'] = admin_cmd::save_remote($content['remote']); |
195 | 198 | $content['msg'] = lang('Remote instance saved'); |
196 | - } catch (Exception $e) { |
|
199 | + } |
|
200 | + catch (Exception $e) { |
|
197 | 201 | $content['msg'] = lang('Error saving').': '.$e->getMessage().' ('.$e->getCode().')'; |
198 | 202 | break; |
199 | 203 | } |
200 | - if ($button == 'apply') break; |
|
204 | + if ($button == 'apply') |
|
205 | + { |
|
206 | + break; |
|
207 | + } |
|
201 | 208 | // fall through for save |
202 | 209 | case 'cancel': |
203 | 210 | unset($content['remote']); |