@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | /** |
83 | 83 | * List defined {im|ex}ports |
84 | 84 | * |
85 | - * @param array $content=null |
|
85 | + * @param array $content |
|
86 | 86 | */ |
87 | 87 | function index($content = null,$msg='') |
88 | 88 | { |
@@ -309,8 +309,9 @@ discard block |
||
309 | 309 | * @param int &$success number of succeded actions |
310 | 310 | * @param int &$failed number of failed actions (not enought permissions) |
311 | 311 | * @param string &$action_msg translated verb for the actions, to be used in a message like %1 entries 'deleted' |
312 | - * @param string/array $session_name 'index' or 'email', or array with session-data depending if we are in the main list or the popup |
|
313 | - * @return boolean true if all actions succeded, false otherwise |
|
312 | + * @param string $session_name 'index' or 'email', or array with session-data depending if we are in the main list or the popup |
|
313 | + * @param string $msg |
|
314 | + * @return null|boolean true if all actions succeded, false otherwise |
|
314 | 315 | */ |
315 | 316 | function action($action,$selected,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg) |
316 | 317 | { |
@@ -940,7 +940,7 @@ |
||
940 | 940 | * Determine if the user is allowed to edit the definition |
941 | 941 | * |
942 | 942 | */ |
943 | - protected function can_edit(Array $definition) |
|
943 | + protected function can_edit(array $definition) |
|
944 | 944 | { |
945 | 945 | if($definition['owner'] && $definition['owner'] == $GLOBALS['egw_info']['user']['account_id']) |
946 | 946 | { |
@@ -81,14 +81,18 @@ discard block |
||
81 | 81 | { |
82 | 82 | $filter = array('name' => '*'); |
83 | 83 | |
84 | - if($GLOBALS['egw_info']['user']['apps']['admin']) { |
|
84 | + if($GLOBALS['egw_info']['user']['apps']['admin']) |
|
85 | + { |
|
85 | 86 | // Any public definition |
86 | 87 | $filter[] = '(owner=0 OR owner IS NULL OR allowed_users IS NOT NULL OR owner = ' . $GLOBALS['egw_info']['user']['account_id'] . ')'; |
87 | - } else { |
|
88 | + } |
|
89 | + else |
|
90 | + { |
|
88 | 91 | // Filter private definitions |
89 | 92 | $filter['owner'] = $GLOBALS['egw_info']['user']['account_id']; |
90 | 93 | $config = Api\Config::read('phpgwapi'); |
91 | - if($config['export_limit'] == 'no' && !Api\Storage\Merge::is_export_limit_excepted()) { |
|
94 | + if($config['export_limit'] == 'no' && !Api\Storage\Merge::is_export_limit_excepted()) |
|
95 | + { |
|
92 | 96 | $filter['type'] = 'import'; |
93 | 97 | } |
94 | 98 | } |
@@ -104,7 +108,10 @@ discard block |
||
104 | 108 | elseif(($button = array_search('pressed',$content['nm']['rows'])) !== false) |
105 | 109 | { |
106 | 110 | $selected = $content['nm']['rows']['selected']; |
107 | - if(count($selected) < 1 || !is_array($selected)) exit(); |
|
111 | + if(count($selected) < 1 || !is_array($selected)) |
|
112 | + { |
|
113 | + exit(); |
|
114 | + } |
|
108 | 115 | switch ($button) |
109 | 116 | { |
110 | 117 | case 'delete_selected' : |
@@ -160,7 +167,8 @@ discard block |
||
160 | 167 | } |
161 | 168 | } |
162 | 169 | |
163 | - if(!is_array($content['nm'])) { |
|
170 | + if(!is_array($content['nm'])) |
|
171 | + { |
|
164 | 172 | $content['nm'] = array( |
165 | 173 | 'get_rows' => 'importexport.importexport_definitions_ui.get_rows', |
166 | 174 | 'no_cat' => true, |
@@ -171,7 +179,10 @@ discard block |
||
171 | 179 | 'row_id' => 'definition_id', |
172 | 180 | 'placeholder_actions' => array('add') |
173 | 181 | ); |
174 | - if($_GET['application']) $content['nm']['col_filter']['application'] = $_GET['application']; |
|
182 | + if($_GET['application']) |
|
183 | + { |
|
184 | + $content['nm']['col_filter']['application'] = $_GET['application']; |
|
185 | + } |
|
175 | 186 | } |
176 | 187 | if(Api\Cache::getSession('importexport', 'index')) |
177 | 188 | { |
@@ -190,17 +201,22 @@ discard block |
||
190 | 201 | ); |
191 | 202 | foreach ($this->plugins as $appname => $options) |
192 | 203 | { |
193 | - if($GLOBALS['egw_info']['user']['apps'][$appname] || $GLOBALS['egw_info']['user']['apps']['admin']) { |
|
204 | + if($GLOBALS['egw_info']['user']['apps'][$appname] || $GLOBALS['egw_info']['user']['apps']['admin']) |
|
205 | + { |
|
194 | 206 | $sel_options['application'][$appname] = lang($appname); |
195 | 207 | } |
196 | 208 | } |
197 | - if($msg) $content['msg'] = $msg; |
|
209 | + if($msg) |
|
210 | + { |
|
211 | + $content['msg'] = $msg; |
|
212 | + } |
|
198 | 213 | |
199 | 214 | $etpl = new Etemplate(self::_appname.'.definition_index'); |
200 | 215 | return $etpl->exec( self::_appname.'.importexport_definitions_ui.index', $content, $sel_options, $readonlys, $preserv ); |
201 | 216 | } |
202 | 217 | |
203 | - private function get_actions() { |
|
218 | + private function get_actions() |
|
219 | + { |
|
204 | 220 | $group = 0; |
205 | 221 | $actions = array( |
206 | 222 | 'edit' => array( |
@@ -319,7 +335,8 @@ discard block |
||
319 | 335 | $this->get_rows($query,$rows,$readonlys); |
320 | 336 | |
321 | 337 | $selected = array(); |
322 | - foreach($rows as $row) { |
|
338 | + foreach($rows as $row) |
|
339 | + { |
|
323 | 340 | $selected[] = $row['definition_id']; |
324 | 341 | } |
325 | 342 | if(!is_array($session_name)) |
@@ -334,18 +351,24 @@ discard block |
||
334 | 351 | |
335 | 352 | $bodefinitions = new importexport_definitions_bo(false, true); |
336 | 353 | |
337 | - switch($action) { |
|
354 | + switch($action) |
|
355 | + { |
|
338 | 356 | case 'allowed': |
339 | 357 | // Field is allowed_users, popup doesn't like _ |
340 | 358 | $action = 'allowed_users'; |
341 | 359 | // Fall through |
342 | 360 | case 'owner': |
343 | 361 | $action_msg = lang('changed'. ' ' . $action); |
344 | - foreach($selected as $id) { |
|
362 | + foreach($selected as $id) |
|
363 | + { |
|
345 | 364 | $definition = $bodefinitions->read((int)$id); |
346 | - if($definition['definition_id']) { |
|
365 | + if($definition['definition_id']) |
|
366 | + { |
|
347 | 367 | // Prevent private with no owner |
348 | - if(!$definition['owner'] && !$settings) $definition['owner'] = $GLOBALS['egw_info']['user']['account_id']; |
|
368 | + if(!$definition['owner'] && !$settings) |
|
369 | + { |
|
370 | + $definition['owner'] = $GLOBALS['egw_info']['user']['account_id']; |
|
371 | + } |
|
349 | 372 | |
350 | 373 | $definition[$action] = $settings; |
351 | 374 | $bodefinitions->save($definition); |
@@ -372,18 +395,22 @@ discard block |
||
372 | 395 | case 'copy': |
373 | 396 | $action_msg = lang('copied'); |
374 | 397 | // Should only be one selected |
375 | - foreach($selected as $id) { |
|
398 | + foreach($selected as $id) |
|
399 | + { |
|
376 | 400 | $definition = $bodefinitions->read((int)$id); |
377 | - if($definition['definition_id']) { |
|
401 | + if($definition['definition_id']) |
|
402 | + { |
|
378 | 403 | unset($definition['definition_id']); |
379 | 404 | $definition['name'] = $settings ? $settings : $definition['name'] . ' copy'; |
380 | 405 | try { |
381 | 406 | $bodefinitions->save($definition); |
382 | - } catch (Exception $e) { |
|
407 | + } |
|
408 | + catch (Exception $e) { |
|
383 | 409 | try { |
384 | 410 | $definition['name'] .= ' ' . $GLOBALS['egw_info']['user']['account_lid']; |
385 | 411 | $bodefinitions->save($definition); |
386 | - } catch (Exception $ex) { |
|
412 | + } |
|
413 | + catch (Exception $ex) { |
|
387 | 414 | $failed++; |
388 | 415 | $msg .= lang('Duplicate name, please choose another.'); |
389 | 416 | continue; |
@@ -396,18 +423,21 @@ discard block |
||
396 | 423 | case 'createexport': |
397 | 424 | $action_msg = lang('created'); |
398 | 425 | // Should only be one selected |
399 | - foreach($selected as $id) { |
|
426 | + foreach($selected as $id) |
|
427 | + { |
|
400 | 428 | $definition = new importexport_definition($id); |
401 | 429 | try { |
402 | 430 | $export = $bodefinitions->export_from_import($definition); |
403 | 431 | $export->save(); |
404 | - } catch (Exception $e) { |
|
432 | + } |
|
433 | + catch (Exception $e) { |
|
405 | 434 | if($export) |
406 | 435 | { |
407 | 436 | try { |
408 | 437 | $export->name = $export->name.' ' . $GLOBALS['egw_info']['user']['account_lid']; |
409 | 438 | $export->save(); |
410 | - } catch (Exception $ex) { |
|
439 | + } |
|
440 | + catch (Exception $ex) { |
|
411 | 441 | $failed++; |
412 | 442 | $msg .= lang('Duplicate name, please choose another.'); |
413 | 443 | continue; |
@@ -425,7 +455,8 @@ discard block |
||
425 | 455 | return !$failed; |
426 | 456 | } |
427 | 457 | |
428 | - public function get_rows(&$query, &$rows, &$readonlys) { |
|
458 | + public function get_rows(&$query, &$rows, &$readonlys) |
|
459 | + { |
|
429 | 460 | $rows = array(); |
430 | 461 | Api\Cache::setSession('importexport', 'index', $query); |
431 | 462 | |
@@ -500,7 +531,10 @@ discard block |
||
500 | 531 | |
501 | 532 | if(is_array($content) &&! $content['edit']) |
502 | 533 | { |
503 | - if(self::_debug) error_log('importexport.wizard->$content '. print_r($content,true)); |
|
534 | + if(self::_debug) |
|
535 | + { |
|
536 | + error_log('importexport.wizard->$content '. print_r($content,true)); |
|
537 | + } |
|
504 | 538 | //foreach($content as $key => $val) error_log(" $key : ".array2string($val)); |
505 | 539 | // fetch plugin object |
506 | 540 | if($content['plugin'] && $content['application']) |
@@ -517,13 +551,18 @@ discard block |
||
517 | 551 | $wizard_plugin = $content['plugin']; |
518 | 552 | } |
519 | 553 | // App translations |
520 | - if($content['application']) Api\Translation::add_app($content['application']); |
|
554 | + if($content['application']) |
|
555 | + { |
|
556 | + Api\Translation::add_app($content['application']); |
|
557 | + } |
|
521 | 558 | |
522 | 559 | $this->plugin = is_object($GLOBALS['egw']->$wizard_plugin) ? $GLOBALS['egw']->$wizard_plugin : new $wizard_plugin; |
523 | 560 | |
524 | 561 | // Global object needs to be the same, or references to plugin don't work |
525 | 562 | if(!is_object($GLOBALS['egw']->importexport_definitions_ui) || $GLOBALS['egw']->importexport_definitions_ui !== $this) |
526 | - $GLOBALS['egw']->importexport_definitions_ui =& $this; |
|
563 | + { |
|
564 | + $GLOBALS['egw']->importexport_definitions_ui =& $this; |
|
565 | + } |
|
527 | 566 | } |
528 | 567 | // deal with buttons even if we are not on ajax |
529 | 568 | if(isset($content['button']) && array_search('pressed',$content['button']) === false && count($content['button']) == 1) |
@@ -653,7 +692,10 @@ discard block |
||
653 | 692 | |
654 | 693 | function wizard_step10(&$content, &$sel_options, &$readonlys, &$preserv) |
655 | 694 | { |
656 | - if(self::_debug) error_log('importexport.importexport_definitions_ui::wizard_step10->$content '.print_r($content,true)); |
|
695 | + if(self::_debug) |
|
696 | + { |
|
697 | + error_log('importexport.importexport_definitions_ui::wizard_step10->$content '.print_r($content,true)); |
|
698 | + } |
|
657 | 699 | |
658 | 700 | // return from step10 |
659 | 701 | if ($content['step'] == 'wizard_step10') |
@@ -675,7 +717,8 @@ discard block |
||
675 | 717 | $content['text'] = $this->steps['wizard_step10']; |
676 | 718 | foreach ($this->plugins as $appname => $options) |
677 | 719 | { |
678 | - if($GLOBALS['egw_info']['user']['apps'][$appname] || $GLOBALS['egw_info']['user']['apps']['admin']) { |
|
720 | + if($GLOBALS['egw_info']['user']['apps'][$appname] || $GLOBALS['egw_info']['user']['apps']['admin']) |
|
721 | + { |
|
679 | 722 | $sel_options['application'][$appname] = lang($appname); |
680 | 723 | } |
681 | 724 | } |
@@ -691,7 +734,10 @@ discard block |
||
691 | 734 | // get plugin |
692 | 735 | function wizard_step20(&$content, &$sel_options, &$readonlys, &$preserv) |
693 | 736 | { |
694 | - if(self::_debug) error_log('importexport.' . get_class($this) . '::wizard_step20->$content '.print_r($content,true)); |
|
737 | + if(self::_debug) |
|
738 | + { |
|
739 | + error_log('importexport.' . get_class($this) . '::wizard_step20->$content '.print_r($content,true)); |
|
740 | + } |
|
695 | 741 | |
696 | 742 | // return from step20 |
697 | 743 | if ($content['step'] == 'wizard_step20') |
@@ -700,11 +746,16 @@ discard block |
||
700 | 746 | { |
701 | 747 | case 'next': |
702 | 748 | // There's no real reason the plugin has to come from any of these, as long as it has a $steps variable |
703 | - if($this->plugin instanceof importexport_iface_import_plugin || $this->plugin instanceof importexport_wizard_basic_import_csv || strpos(get_class($this->plugin), 'import') !== false) { |
|
749 | + if($this->plugin instanceof importexport_iface_import_plugin || $this->plugin instanceof importexport_wizard_basic_import_csv || strpos(get_class($this->plugin), 'import') !== false) |
|
750 | + { |
|
704 | 751 | $content['type'] = 'import'; |
705 | - } elseif($this->plugin instanceof importexport_iface_export_plugin || $this->plugin instanceof importexport_wizard_basic_export_csv || strpos(get_class($this->plugin),'export') !== false) { |
|
752 | + } |
|
753 | + elseif($this->plugin instanceof importexport_iface_export_plugin || $this->plugin instanceof importexport_wizard_basic_export_csv || strpos(get_class($this->plugin),'export') !== false) |
|
754 | + { |
|
706 | 755 | $content['type'] = 'export'; |
707 | - } else { |
|
756 | + } |
|
757 | + else |
|
758 | + { |
|
708 | 759 | throw new Api\Exception('Invalid plugin'); |
709 | 760 | } |
710 | 761 | return $this->get_step($content['step'],1); |
@@ -722,9 +773,14 @@ discard block |
||
722 | 773 | { |
723 | 774 | $content['text'] = $this->steps['wizard_step20']; |
724 | 775 | $config = Api\Config::read('phpgwapi'); |
725 | - foreach ($this->plugins[$content['application']] as $type => $plugins) { |
|
726 | - if($config['export_limit'] == 'no' && !$GLOBALS['egw_info']['user']['apps']['admin'] && $type == 'export') continue; |
|
727 | - foreach($plugins as $plugin => $name) { |
|
776 | + foreach ($this->plugins[$content['application']] as $type => $plugins) |
|
777 | + { |
|
778 | + if($config['export_limit'] == 'no' && !$GLOBALS['egw_info']['user']['apps']['admin'] && $type == 'export') |
|
779 | + { |
|
780 | + continue; |
|
781 | + } |
|
782 | + foreach($plugins as $plugin => $name) |
|
783 | + { |
|
728 | 784 | $sel_options['plugin'][$plugin] = $name; |
729 | 785 | } |
730 | 786 | } |
@@ -740,7 +796,10 @@ discard block |
||
740 | 796 | // name |
741 | 797 | function wizard_step21(&$content, &$sel_options, &$readonlys, &$preserv) |
742 | 798 | { |
743 | - if(self::_debug) error_log('importexport.importexport_definitions_ui::wizard_step21->$content '.print_r($content,true)); |
|
799 | + if(self::_debug) |
|
800 | + { |
|
801 | + error_log('importexport.importexport_definitions_ui::wizard_step21->$content '.print_r($content,true)); |
|
802 | + } |
|
744 | 803 | |
745 | 804 | // Check for duplicate name |
746 | 805 | $duplicate = isset($content['duplicate_error']); |
@@ -752,7 +811,8 @@ discard block |
||
752 | 811 | { |
753 | 812 | throw new Exception('Already exists'); |
754 | 813 | } |
755 | - } catch (Exception $e) { |
|
814 | + } |
|
815 | + catch (Exception $e) { |
|
756 | 816 | // throw new Exception('Already exists'); |
757 | 817 | $content['duplicate_error'] = lang('Duplicate name, please choose another.'); |
758 | 818 | |
@@ -763,13 +823,16 @@ discard block |
||
763 | 823 | $content['name'] .'-'. Api\DateTime::to('now', true), |
764 | 824 | //$content['name'] .'-'. rand(0,100), |
765 | 825 | ); |
766 | - foreach($suggestions as $key => $suggestion) { |
|
826 | + foreach($suggestions as $key => $suggestion) |
|
827 | + { |
|
767 | 828 | $sug_definition = new importexport_definition($suggestion); |
768 | - if($sug_definition->definition_id) { |
|
829 | + if($sug_definition->definition_id) |
|
830 | + { |
|
769 | 831 | unset($suggestions[$key]); |
770 | 832 | } |
771 | 833 | } |
772 | - if($suggestions) { |
|
834 | + if($suggestions) |
|
835 | + { |
|
773 | 836 | $content['duplicate_error'] .= ' '. lang('Try')." \n" . implode("\n", $suggestions); |
774 | 837 | } |
775 | 838 | return $this->get_step($content['step'],0); |
@@ -806,7 +869,10 @@ discard block |
||
806 | 869 | // allowed users |
807 | 870 | function wizard_step90(&$content, &$sel_options, &$readonlys, &$preserv) |
808 | 871 | { |
809 | - if(self::_debug) error_log('importexport.importexport_definitions_ui::wizard_step90->$content '.print_r($content,true)); |
|
872 | + if(self::_debug) |
|
873 | + { |
|
874 | + error_log('importexport.importexport_definitions_ui::wizard_step90->$content '.print_r($content,true)); |
|
875 | + } |
|
810 | 876 | |
811 | 877 | // return from step90 |
812 | 878 | if ($content['step'] == 'wizard_step90') |
@@ -876,7 +942,10 @@ discard block |
||
876 | 942 | |
877 | 943 | function wizard_finish(&$content) |
878 | 944 | { |
879 | - if(self::_debug) error_log('importexport.importexport_definitions_ui::wizard_finish->$content '.print_r($content,true)); |
|
945 | + if(self::_debug) |
|
946 | + { |
|
947 | + error_log('importexport.importexport_definitions_ui::wizard_finish->$content '.print_r($content,true)); |
|
948 | + } |
|
880 | 949 | // Take out some UI leavings |
881 | 950 | unset($content['text']); |
882 | 951 | unset($content['step']); |
@@ -905,7 +974,8 @@ discard block |
||
905 | 974 | if($content['update']) |
906 | 975 | { |
907 | 976 | $applist = importexport_helper_functions::get_apps('all', true); |
908 | - foreach($applist as $appname) { |
|
977 | + foreach($applist as $appname) |
|
978 | + { |
|
909 | 979 | importexport_helper_functions::load_defaults($appname); |
910 | 980 | } |
911 | 981 | return $this->index(); |
@@ -971,7 +1041,9 @@ discard block |
||
971 | 1041 | { |
972 | 1042 | Api\Config::save_value($key, $value, 'importexport'); |
973 | 1043 | } |
974 | - } elseif (isset($content['cancel'])) { |
|
1044 | + } |
|
1045 | + elseif (isset($content['cancel'])) |
|
1046 | + { |
|
975 | 1047 | $GLOBALS['egw']->redirect_link('/admin/index.php'); |
976 | 1048 | } |
977 | 1049 | |
@@ -985,7 +1057,10 @@ discard block |
||
985 | 1057 | unset($sel_options['import_charsets'][strtoupper($charset)]); |
986 | 1058 | } |
987 | 1059 | |
988 | - if(!$data['update']) $data['update'] = 'request'; |
|
1060 | + if(!$data['update']) |
|
1061 | + { |
|
1062 | + $data['update'] = 'request'; |
|
1063 | + } |
|
989 | 1064 | |
990 | 1065 | $GLOBALS['egw_info']['flags']['app_header'] = lang('Site configuration') . ' - ' . lang(self::_appname); |
991 | 1066 | $etpl = new etemplate(self::_appname.'.config'); |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | $GLOBALS['egw_info']['flags']['currentapp'] = self::_appname; |
61 | 61 | |
62 | 62 | $this->etpl = new Etemplate(); |
63 | - $this->clock = Api\Html::image(self::_appname,'clock'); |
|
63 | + $this->clock = Api\Html::image(self::_appname, 'clock'); |
|
64 | 64 | $this->steps = array( |
65 | 65 | 'wizard_step10' => lang('Choose an application'), |
66 | 66 | 'wizard_step20' => lang('Choose a plugin'), |
@@ -77,18 +77,18 @@ discard block |
||
77 | 77 | * |
78 | 78 | * @param array $content=null |
79 | 79 | */ |
80 | - function index($content = null,$msg='') |
|
80 | + function index($content = null, $msg = '') |
|
81 | 81 | { |
82 | 82 | $filter = array('name' => '*'); |
83 | 83 | |
84 | - if($GLOBALS['egw_info']['user']['apps']['admin']) { |
|
84 | + if ($GLOBALS['egw_info']['user']['apps']['admin']) { |
|
85 | 85 | // Any public definition |
86 | - $filter[] = '(owner=0 OR owner IS NULL OR allowed_users IS NOT NULL OR owner = ' . $GLOBALS['egw_info']['user']['account_id'] . ')'; |
|
86 | + $filter[] = '(owner=0 OR owner IS NULL OR allowed_users IS NOT NULL OR owner = '.$GLOBALS['egw_info']['user']['account_id'].')'; |
|
87 | 87 | } else { |
88 | 88 | // Filter private definitions |
89 | 89 | $filter['owner'] = $GLOBALS['egw_info']['user']['account_id']; |
90 | 90 | $config = Api\Config::read('phpgwapi'); |
91 | - if($config['export_limit'] == 'no' && !Api\Storage\Merge::is_export_limit_excepted()) { |
|
91 | + if ($config['export_limit'] == 'no' && !Api\Storage\Merge::is_export_limit_excepted()) { |
|
92 | 92 | $filter['type'] = 'import'; |
93 | 93 | } |
94 | 94 | } |
@@ -99,12 +99,12 @@ discard block |
||
99 | 99 | if (isset($content['nm']['rows']['delete'])) |
100 | 100 | { |
101 | 101 | $content['nm']['action'] = 'delete'; |
102 | - $content['nm']['selected'] = array_keys($content['nm']['rows']['delete'],'pressed'); |
|
102 | + $content['nm']['selected'] = array_keys($content['nm']['rows']['delete'], 'pressed'); |
|
103 | 103 | } |
104 | - elseif(($button = array_search('pressed',$content['nm']['rows'])) !== false) |
|
104 | + elseif (($button = array_search('pressed', $content['nm']['rows'])) !== false) |
|
105 | 105 | { |
106 | 106 | $selected = $content['nm']['rows']['selected']; |
107 | - if(count($selected) < 1 || !is_array($selected)) exit(); |
|
107 | + if (count($selected) < 1 || !is_array($selected)) exit(); |
|
108 | 108 | switch ($button) |
109 | 109 | { |
110 | 110 | case 'delete_selected' : |
@@ -126,54 +126,54 @@ discard block |
||
126 | 126 | else |
127 | 127 | { |
128 | 128 | // Action has an additional parameter |
129 | - if(in_array($content['nm']['action'], array('owner', 'allowed'))) |
|
129 | + if (in_array($content['nm']['action'], array('owner', 'allowed'))) |
|
130 | 130 | { |
131 | 131 | $action = $content['nm']['action']; |
132 | - if($content['nm']['action'] == 'allowed') |
|
132 | + if ($content['nm']['action'] == 'allowed') |
|
133 | 133 | { |
134 | 134 | $content['allowed'] = $content['allowed_popup']['allowed_private'] == 'true' ? null : ( |
135 | - $content['allowed_popup']['all_users']=='true' ? 'all' : implode(',',$content['allowed_popup']['allowed']) |
|
135 | + $content['allowed_popup']['all_users'] == 'true' ? 'all' : implode(',', $content['allowed_popup']['allowed']) |
|
136 | 136 | ); |
137 | 137 | } |
138 | 138 | else |
139 | 139 | { |
140 | 140 | $content['owner'] = $content['owner_popup']['owner']; |
141 | 141 | } |
142 | - if(is_array($content[$content['nm']['action']])) |
|
142 | + if (is_array($content[$content['nm']['action']])) |
|
143 | 143 | { |
144 | - $content[$content['nm']['action']] = implode(',',$content[$content['nm']['action']]); |
|
144 | + $content[$content['nm']['action']] = implode(',', $content[$content['nm']['action']]); |
|
145 | 145 | } |
146 | - $content['nm']['action'] .= '_' . $content[$action]; |
|
146 | + $content['nm']['action'] .= '_'.$content[$action]; |
|
147 | 147 | unset($content[$action]); |
148 | 148 | unset($content['allowed_popup']); |
149 | 149 | } |
150 | - if ($this->action($content['nm']['action'],$content['nm']['selected'],$content['nm']['select_all'], |
|
151 | - $success,$failed,$action_msg,'index',$msg)) |
|
150 | + if ($this->action($content['nm']['action'], $content['nm']['selected'], $content['nm']['select_all'], |
|
151 | + $success, $failed, $action_msg, 'index', $msg)) |
|
152 | 152 | { |
153 | - $msg .= lang('%1 definition(s) %2',$success,$action_msg); |
|
153 | + $msg .= lang('%1 definition(s) %2', $success, $action_msg); |
|
154 | 154 | } |
155 | - elseif(empty($msg)) |
|
155 | + elseif (empty($msg)) |
|
156 | 156 | { |
157 | - $msg .= lang('%1 definition(s) %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed); |
|
157 | + $msg .= lang('%1 definition(s) %2, %3 failed because of insufficent rights !!!', $success, $action_msg, $failed); |
|
158 | 158 | } |
159 | 159 | } |
160 | 160 | } |
161 | 161 | } |
162 | 162 | |
163 | - if(!is_array($content['nm'])) { |
|
163 | + if (!is_array($content['nm'])) { |
|
164 | 164 | $content['nm'] = array( |
165 | 165 | 'get_rows' => 'importexport.importexport_definitions_ui.get_rows', |
166 | 166 | 'no_cat' => true, |
167 | 167 | 'no_filter' => true, |
168 | 168 | 'no_filter2' => true, |
169 | - 'csv_fields' => false, // Disable CSV export, uses own export |
|
170 | - 'default_cols' => '!actions', // switch legacy actions column and row off by default |
|
169 | + 'csv_fields' => false, // Disable CSV export, uses own export |
|
170 | + 'default_cols' => '!actions', // switch legacy actions column and row off by default |
|
171 | 171 | 'row_id' => 'definition_id', |
172 | 172 | 'placeholder_actions' => array('add') |
173 | 173 | ); |
174 | - if($_GET['application']) $content['nm']['col_filter']['application'] = $_GET['application']; |
|
174 | + if ($_GET['application']) $content['nm']['col_filter']['application'] = $_GET['application']; |
|
175 | 175 | } |
176 | - if(Api\Cache::getSession('importexport', 'index')) |
|
176 | + if (Api\Cache::getSession('importexport', 'index')) |
|
177 | 177 | { |
178 | 178 | $content['nm'] = array_merge($content['nm'], Api\Cache::getSession('importexport', 'index')); |
179 | 179 | } |
@@ -190,14 +190,14 @@ discard block |
||
190 | 190 | ); |
191 | 191 | foreach ($this->plugins as $appname => $options) |
192 | 192 | { |
193 | - if($GLOBALS['egw_info']['user']['apps'][$appname] || $GLOBALS['egw_info']['user']['apps']['admin']) { |
|
193 | + if ($GLOBALS['egw_info']['user']['apps'][$appname] || $GLOBALS['egw_info']['user']['apps']['admin']) { |
|
194 | 194 | $sel_options['application'][$appname] = lang($appname); |
195 | 195 | } |
196 | 196 | } |
197 | - if($msg) $content['msg'] = $msg; |
|
197 | + if ($msg) $content['msg'] = $msg; |
|
198 | 198 | |
199 | 199 | $etpl = new Etemplate(self::_appname.'.definition_index'); |
200 | - return $etpl->exec( self::_appname.'.importexport_definitions_ui.index', $content, $sel_options, $readonlys, $preserv ); |
|
200 | + return $etpl->exec(self::_appname.'.importexport_definitions_ui.index', $content, $sel_options, $readonlys, $preserv); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | private function get_actions() { |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | ); |
287 | 287 | |
288 | 288 | // Unset admin actions |
289 | - if(!$GLOBALS['egw_info']['user']['apps']['admin']) |
|
289 | + if (!$GLOBALS['egw_info']['user']['apps']['admin']) |
|
290 | 290 | { |
291 | 291 | unset($actions['schedule']); |
292 | 292 | } |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | * @param string/array $session_name 'index' or 'email', or array with session-data depending if we are in the main list or the popup |
306 | 306 | * @return boolean true if all actions succeded, false otherwise |
307 | 307 | */ |
308 | - function action($action,$selected,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg) |
|
308 | + function action($action, $selected, $use_all, &$success, &$failed, &$action_msg, $session_name, &$msg) |
|
309 | 309 | { |
310 | 310 | //error_log( __METHOD__."('$action', ".array2string($selected).', '.array2string($use_all).",,, '$session_name')"); |
311 | 311 | if ($use_all) |
@@ -313,16 +313,16 @@ discard block |
||
313 | 313 | // get the whole selection |
314 | 314 | $old_query = $query = is_array($session_name) ? $session_name : Api\Cache::getSession('importexport', $session_name); |
315 | 315 | |
316 | - @set_time_limit(0); // switch off the execution time limit, as it's for big selections to small |
|
317 | - $query['num_rows'] = -1; // all |
|
318 | - $query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session |
|
319 | - $this->get_rows($query,$rows,$readonlys); |
|
316 | + @set_time_limit(0); // switch off the execution time limit, as it's for big selections to small |
|
317 | + $query['num_rows'] = -1; // all |
|
318 | + $query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session |
|
319 | + $this->get_rows($query, $rows, $readonlys); |
|
320 | 320 | |
321 | 321 | $selected = array(); |
322 | - foreach($rows as $row) { |
|
322 | + foreach ($rows as $row) { |
|
323 | 323 | $selected[] = $row['definition_id']; |
324 | 324 | } |
325 | - if(!is_array($session_name)) |
|
325 | + if (!is_array($session_name)) |
|
326 | 326 | { |
327 | 327 | // Restore old query |
328 | 328 | Api\Cache::setSession('importexport', $session_name, $old_query); |
@@ -334,18 +334,18 @@ discard block |
||
334 | 334 | |
335 | 335 | $bodefinitions = new importexport_definitions_bo(false, true); |
336 | 336 | |
337 | - switch($action) { |
|
337 | + switch ($action) { |
|
338 | 338 | case 'allowed': |
339 | 339 | // Field is allowed_users, popup doesn't like _ |
340 | 340 | $action = 'allowed_users'; |
341 | 341 | // Fall through |
342 | 342 | case 'owner': |
343 | - $action_msg = lang('changed'. ' ' . $action); |
|
344 | - foreach($selected as $id) { |
|
343 | + $action_msg = lang('changed'.' '.$action); |
|
344 | + foreach ($selected as $id) { |
|
345 | 345 | $definition = $bodefinitions->read((int)$id); |
346 | - if($definition['definition_id']) { |
|
346 | + if ($definition['definition_id']) { |
|
347 | 347 | // Prevent private with no owner |
348 | - if(!$definition['owner'] && !$settings) $definition['owner'] = $GLOBALS['egw_info']['user']['account_id']; |
|
348 | + if (!$definition['owner'] && !$settings) $definition['owner'] = $GLOBALS['egw_info']['user']['account_id']; |
|
349 | 349 | |
350 | 350 | $definition[$action] = $settings; |
351 | 351 | $bodefinitions->save($definition); |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | $mime_type = ($GLOBALS['egw']->html->user_agent == 'msie' || $GLOBALS['egw']->html->user_agent == 'opera') ? |
364 | 364 | 'application/octetstream' : 'application/octet-stream'; |
365 | 365 | $name = 'importexport_definition.xml'; |
366 | - header('Content-Type: ' . $mime_type); |
|
366 | + header('Content-Type: '.$mime_type); |
|
367 | 367 | header('Content-Disposition: attachment; filename="'.$name.'"'); |
368 | 368 | echo $bodefinitions->export($selected); |
369 | 369 | exit(); |
@@ -372,16 +372,16 @@ discard block |
||
372 | 372 | case 'copy': |
373 | 373 | $action_msg = lang('copied'); |
374 | 374 | // Should only be one selected |
375 | - foreach($selected as $id) { |
|
375 | + foreach ($selected as $id) { |
|
376 | 376 | $definition = $bodefinitions->read((int)$id); |
377 | - if($definition['definition_id']) { |
|
377 | + if ($definition['definition_id']) { |
|
378 | 378 | unset($definition['definition_id']); |
379 | - $definition['name'] = $settings ? $settings : $definition['name'] . ' copy'; |
|
379 | + $definition['name'] = $settings ? $settings : $definition['name'].' copy'; |
|
380 | 380 | try { |
381 | 381 | $bodefinitions->save($definition); |
382 | 382 | } catch (Exception $e) { |
383 | 383 | try { |
384 | - $definition['name'] .= ' ' . $GLOBALS['egw_info']['user']['account_lid']; |
|
384 | + $definition['name'] .= ' '.$GLOBALS['egw_info']['user']['account_lid']; |
|
385 | 385 | $bodefinitions->save($definition); |
386 | 386 | } catch (Exception $ex) { |
387 | 387 | $failed++; |
@@ -396,16 +396,16 @@ discard block |
||
396 | 396 | case 'createexport': |
397 | 397 | $action_msg = lang('created'); |
398 | 398 | // Should only be one selected |
399 | - foreach($selected as $id) { |
|
399 | + foreach ($selected as $id) { |
|
400 | 400 | $definition = new importexport_definition($id); |
401 | 401 | try { |
402 | 402 | $export = $bodefinitions->export_from_import($definition); |
403 | 403 | $export->save(); |
404 | 404 | } catch (Exception $e) { |
405 | - if($export) |
|
405 | + if ($export) |
|
406 | 406 | { |
407 | 407 | try { |
408 | - $export->name = $export->name.' ' . $GLOBALS['egw_info']['user']['account_lid']; |
|
408 | + $export->name = $export->name.' '.$GLOBALS['egw_info']['user']['account_lid']; |
|
409 | 409 | $export->save(); |
410 | 410 | } catch (Exception $ex) { |
411 | 411 | $failed++; |
@@ -430,10 +430,10 @@ discard block |
||
430 | 430 | Api\Cache::setSession('importexport', 'index', $query); |
431 | 431 | |
432 | 432 | // Special handling for allowed users 'private' |
433 | - if($query['col_filter']['allowed_users'] == 'private') |
|
433 | + if ($query['col_filter']['allowed_users'] == 'private') |
|
434 | 434 | { |
435 | 435 | unset($query['col_filter']['allowed_users']); |
436 | - $query['col_filter'][] = 'allowed_users = ' . $GLOBALS['egw']->db->quote(',,'); |
|
436 | + $query['col_filter'][] = 'allowed_users = '.$GLOBALS['egw']->db->quote(',,'); |
|
437 | 437 | } |
438 | 438 | $bodefinitions = new importexport_definitions_bo($query['col_filter'], true); |
439 | 439 | // We don't care about readonlys for the UI |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | */ |
449 | 449 | function edit() |
450 | 450 | { |
451 | - if(!$_definition = $_GET['definition']) |
|
451 | + if (!$_definition = $_GET['definition']) |
|
452 | 452 | { |
453 | 453 | $content = array( |
454 | 454 | 'edit' => true, |
@@ -457,11 +457,11 @@ discard block |
||
457 | 457 | ); |
458 | 458 | |
459 | 459 | // Jump to a step |
460 | - if($_GET['step']) |
|
460 | + if ($_GET['step']) |
|
461 | 461 | { |
462 | 462 | $content['edit'] = false; |
463 | 463 | // Wizard will process previous step, then advance |
464 | - $content['step'] = $this->get_step($_GET['step'],-1); |
|
464 | + $content['step'] = $this->get_step($_GET['step'], -1); |
|
465 | 465 | $content['button']['next'] = 'pressed'; |
466 | 466 | $this->wizard($content); |
467 | 467 | } |
@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | } |
473 | 473 | return; |
474 | 474 | } |
475 | - if(is_numeric($_GET['definition'])) |
|
475 | + if (is_numeric($_GET['definition'])) |
|
476 | 476 | { |
477 | 477 | $definition = (int)$_GET['definition']; |
478 | 478 | } |
@@ -484,31 +484,31 @@ discard block |
||
484 | 484 | $definition = $bodefinitions->read($definition); |
485 | 485 | $definition['edit'] = true; |
486 | 486 | // Jump to a step |
487 | - if($_GET['step']) |
|
487 | + if ($_GET['step']) |
|
488 | 488 | { |
489 | 489 | $definition['edit'] = false; |
490 | 490 | // Wizard will process previous step, then advance |
491 | - $definition['step'] = $_GET['step'];; |
|
491 | + $definition['step'] = $_GET['step']; ; |
|
492 | 492 | $definition['button'] = array('next' => 'pressed'); |
493 | 493 | } |
494 | 494 | $this->wizard($definition); |
495 | 495 | } |
496 | 496 | |
497 | - function wizard($content = null, $msg='') |
|
497 | + function wizard($content = null, $msg = '') |
|
498 | 498 | { |
499 | 499 | $this->etpl->read('importexport.wizardbox'); |
500 | 500 | |
501 | - if(is_array($content) &&! $content['edit']) |
|
501 | + if (is_array($content) && !$content['edit']) |
|
502 | 502 | { |
503 | - if(self::_debug) error_log('importexport.wizard->$content '. print_r($content,true)); |
|
503 | + if (self::_debug) error_log('importexport.wizard->$content '.print_r($content, true)); |
|
504 | 504 | //foreach($content as $key => $val) error_log(" $key : ".array2string($val)); |
505 | 505 | // fetch plugin object |
506 | - if($content['plugin'] && $content['application']) |
|
506 | + if ($content['plugin'] && $content['application']) |
|
507 | 507 | { |
508 | - $wizard_name = $content['application'] . '_wizard_' . str_replace($content['application'] . '_', '', $content['plugin']); |
|
508 | + $wizard_name = $content['application'].'_wizard_'.str_replace($content['application'].'_', '', $content['plugin']); |
|
509 | 509 | |
510 | 510 | // we need to deal with the wizard object if exists |
511 | - if (file_exists(EGW_SERVER_ROOT . '/'. $content['application']."/inc/class.$wizard_name.inc.php")) |
|
511 | + if (file_exists(EGW_SERVER_ROOT.'/'.$content['application']."/inc/class.$wizard_name.inc.php")) |
|
512 | 512 | { |
513 | 513 | $wizard_plugin = $wizard_name; |
514 | 514 | } |
@@ -517,38 +517,38 @@ discard block |
||
517 | 517 | $wizard_plugin = $content['plugin']; |
518 | 518 | } |
519 | 519 | // App translations |
520 | - if($content['application']) Api\Translation::add_app($content['application']); |
|
520 | + if ($content['application']) Api\Translation::add_app($content['application']); |
|
521 | 521 | |
522 | 522 | $this->plugin = is_object($GLOBALS['egw']->$wizard_plugin) ? $GLOBALS['egw']->$wizard_plugin : new $wizard_plugin; |
523 | 523 | |
524 | 524 | // Global object needs to be the same, or references to plugin don't work |
525 | - if(!is_object($GLOBALS['egw']->importexport_definitions_ui) || $GLOBALS['egw']->importexport_definitions_ui !== $this) |
|
526 | - $GLOBALS['egw']->importexport_definitions_ui =& $this; |
|
525 | + if (!is_object($GLOBALS['egw']->importexport_definitions_ui) || $GLOBALS['egw']->importexport_definitions_ui !== $this) |
|
526 | + $GLOBALS['egw']->importexport_definitions_ui = & $this; |
|
527 | 527 | } |
528 | 528 | // deal with buttons even if we are not on ajax |
529 | - if(isset($content['button']) && array_search('pressed',$content['button']) === false && count($content['button']) == 1) |
|
529 | + if (isset($content['button']) && array_search('pressed', $content['button']) === false && count($content['button']) == 1) |
|
530 | 530 | { |
531 | 531 | $button = array_keys($content['button']); |
532 | 532 | $content['button'] = array($button[0] => 'pressed'); |
533 | 533 | } |
534 | 534 | |
535 | 535 | // post process submitted step |
536 | - if($content['step']) |
|
536 | + if ($content['step']) |
|
537 | 537 | { |
538 | - if(!$this->can_edit($content)) |
|
538 | + if (!$this->can_edit($content)) |
|
539 | 539 | { |
540 | 540 | // Each step changes definition, reload it |
541 | 541 | $bodefinitions = new importexport_definitions_bo(); |
542 | 542 | $definition = $bodefinitions->read($content); |
543 | 543 | $content = $definition + array('step' => $content['step'], 'button' => $content['button']); |
544 | 544 | } |
545 | - if(!key_exists($content['step'],$this->steps)) |
|
545 | + if (!key_exists($content['step'], $this->steps)) |
|
546 | 546 | { |
547 | - $next_step = $this->plugin->{$content['step']}($content,$sel_options,$readonlys,$preserv); |
|
547 | + $next_step = $this->plugin->{$content['step']}($content, $sel_options, $readonlys, $preserv); |
|
548 | 548 | } |
549 | 549 | else |
550 | 550 | { |
551 | - $next_step = $this->{$content['step']}($content,$sel_options,$readonlys,$preserv); |
|
551 | + $next_step = $this->{$content['step']}($content, $sel_options, $readonlys, $preserv); |
|
552 | 552 | } |
553 | 553 | } |
554 | 554 | else |
@@ -560,23 +560,23 @@ discard block |
||
560 | 560 | $sel_options = $readonlys = $preserv = array(); |
561 | 561 | |
562 | 562 | // Disable finish button if required fields are missing |
563 | - if(!$content['name'] || !$content['type'] || !$content['plugin']) |
|
563 | + if (!$content['name'] || !$content['type'] || !$content['plugin']) |
|
564 | 564 | { |
565 | 565 | $readonlys['button[finish]'] = true; |
566 | 566 | } |
567 | 567 | do |
568 | 568 | { |
569 | - if(!key_exists($next_step,$this->steps)) |
|
569 | + if (!key_exists($next_step, $this->steps)) |
|
570 | 570 | { |
571 | - $this->wizard_content_template = $this->plugin->$next_step($content,$sel_options,$readonlys,$preserv); |
|
571 | + $this->wizard_content_template = $this->plugin->$next_step($content, $sel_options, $readonlys, $preserv); |
|
572 | 572 | } |
573 | 573 | else |
574 | 574 | { |
575 | - $this->wizard_content_template = $this->$next_step($content,$sel_options,$readonlys,$preserv); |
|
575 | + $this->wizard_content_template = $this->$next_step($content, $sel_options, $readonlys, $preserv); |
|
576 | 576 | } |
577 | - if($this->wizard_content_template == self::SKIP) |
|
577 | + if ($this->wizard_content_template == self::SKIP) |
|
578 | 578 | { |
579 | - if(!key_exists($content['step'],$this->steps)) |
|
579 | + if (!key_exists($content['step'], $this->steps)) |
|
580 | 580 | { |
581 | 581 | $next_step = $this->plugin->{$content['step']}($content); |
582 | 582 | } |
@@ -585,9 +585,9 @@ discard block |
||
585 | 585 | $next_step = $this->{$content['step']}($content); |
586 | 586 | } |
587 | 587 | } |
588 | - } while($this->wizard_content_template == self::SKIP); |
|
588 | + } while ($this->wizard_content_template == self::SKIP); |
|
589 | 589 | |
590 | - if(!$this->can_edit($content)) |
|
590 | + if (!$this->can_edit($content)) |
|
591 | 591 | { |
592 | 592 | $readonlys[$this->wizard_content_template] = true; |
593 | 593 | $preserve = $content; |
@@ -596,21 +596,21 @@ discard block |
||
596 | 596 | |
597 | 597 | unset($content['button']); |
598 | 598 | $content['wizard_content'] = $this->wizard_content_template; |
599 | - $this->etpl->exec(self::_appname.'.importexport_definitions_ui.wizard',$content,$sel_options,$readonlys,$preserv,2); |
|
599 | + $this->etpl->exec(self::_appname.'.importexport_definitions_ui.wizard', $content, $sel_options, $readonlys, $preserv, 2); |
|
600 | 600 | } |
601 | 601 | else |
602 | 602 | { |
603 | 603 | // initial content |
604 | 604 | $sel_options = $readonlys = $preserv = array(); |
605 | 605 | $readonlys['button[previous]'] = true; |
606 | - if($content['edit']) |
|
606 | + if ($content['edit']) |
|
607 | 607 | { |
608 | 608 | unset ($content['edit']); |
609 | 609 | } |
610 | 610 | |
611 | 611 | $this->wizard_content_template = $this->wizard_step10($content, $sel_options, $readonlys, $preserv); |
612 | 612 | |
613 | - if(!$this->can_edit($content)) |
|
613 | + if (!$this->can_edit($content)) |
|
614 | 614 | { |
615 | 615 | $readonlys[$this->wizard_content_template] = true; |
616 | 616 | $preserve = $content; |
@@ -618,7 +618,7 @@ discard block |
||
618 | 618 | } |
619 | 619 | |
620 | 620 | $content['wizard_content'] = $this->wizard_content_template; |
621 | - $this->etpl->exec(self::_appname.'.importexport_definitions_ui.wizard',$content,$sel_options,$readonlys,$preserv,2); |
|
621 | + $this->etpl->exec(self::_appname.'.importexport_definitions_ui.wizard', $content, $sel_options, $readonlys, $preserv, 2); |
|
622 | 622 | } |
623 | 623 | } |
624 | 624 | |
@@ -629,31 +629,31 @@ discard block |
||
629 | 629 | * @param int $step_width |
630 | 630 | * @return string containing function name of next step |
631 | 631 | */ |
632 | - function get_step ($curr_step, $step_width) |
|
632 | + function get_step($curr_step, $step_width) |
|
633 | 633 | { |
634 | 634 | /*if($content['plugin'] && $content['application']&& !is_object($this->plugin)) |
635 | 635 | { |
636 | 636 | $plugin_definition = $this->plugins[$content['application']][$content['plugin']]['definition']; |
637 | 637 | if($plugin_definition) $this->plugin = new $plugin_definition; |
638 | 638 | }*/ |
639 | - if(is_object($this->plugin) && is_array($this->plugin->steps)) |
|
639 | + if (is_object($this->plugin) && is_array($this->plugin->steps)) |
|
640 | 640 | { |
641 | - $steps = array_merge($this->steps,$this->plugin->steps); |
|
642 | - $steps = array_flip($steps); asort($steps); $steps = array_flip($steps); |
|
641 | + $steps = array_merge($this->steps, $this->plugin->steps); |
|
642 | + $steps = array_flip($steps); asort($steps); $steps = array_flip($steps); |
|
643 | 643 | } |
644 | 644 | else |
645 | 645 | { |
646 | 646 | $steps = $this->steps; |
647 | 647 | } |
648 | 648 | $step_keys = array_keys($steps); |
649 | - $nn = array_search($curr_step,$step_keys)+(int)$step_width; |
|
650 | - return (key_exists($nn,$step_keys)) ? $step_keys[$nn] : 'wizard_finish'; |
|
649 | + $nn = array_search($curr_step, $step_keys) + (int)$step_width; |
|
650 | + return (key_exists($nn, $step_keys)) ? $step_keys[$nn] : 'wizard_finish'; |
|
651 | 651 | } |
652 | 652 | |
653 | 653 | |
654 | 654 | function wizard_step10(&$content, &$sel_options, &$readonlys, &$preserv) |
655 | 655 | { |
656 | - if(self::_debug) error_log('importexport.importexport_definitions_ui::wizard_step10->$content '.print_r($content,true)); |
|
656 | + if (self::_debug) error_log('importexport.importexport_definitions_ui::wizard_step10->$content '.print_r($content, true)); |
|
657 | 657 | |
658 | 658 | // return from step10 |
659 | 659 | if ($content['step'] == 'wizard_step10') |
@@ -661,11 +661,11 @@ discard block |
||
661 | 661 | switch (array_search('pressed', $content['button'])) |
662 | 662 | { |
663 | 663 | case 'next': |
664 | - return $this->get_step($content['step'],1); |
|
664 | + return $this->get_step($content['step'], 1); |
|
665 | 665 | case 'finish': |
666 | 666 | return 'wizard_finish'; |
667 | 667 | default : |
668 | - return $this->wizard_step10($content,$sel_options,$readonlys,$preserv); |
|
668 | + return $this->wizard_step10($content, $sel_options, $readonlys, $preserv); |
|
669 | 669 | } |
670 | 670 | |
671 | 671 | } |
@@ -675,7 +675,7 @@ discard block |
||
675 | 675 | $content['text'] = $this->steps['wizard_step10']; |
676 | 676 | foreach ($this->plugins as $appname => $options) |
677 | 677 | { |
678 | - if($GLOBALS['egw_info']['user']['apps'][$appname] || $GLOBALS['egw_info']['user']['apps']['admin']) { |
|
678 | + if ($GLOBALS['egw_info']['user']['apps'][$appname] || $GLOBALS['egw_info']['user']['apps']['admin']) { |
|
679 | 679 | $sel_options['application'][$appname] = lang($appname); |
680 | 680 | } |
681 | 681 | } |
@@ -691,7 +691,7 @@ discard block |
||
691 | 691 | // get plugin |
692 | 692 | function wizard_step20(&$content, &$sel_options, &$readonlys, &$preserv) |
693 | 693 | { |
694 | - if(self::_debug) error_log('importexport.' . get_class($this) . '::wizard_step20->$content '.print_r($content,true)); |
|
694 | + if (self::_debug) error_log('importexport.'.get_class($this).'::wizard_step20->$content '.print_r($content, true)); |
|
695 | 695 | |
696 | 696 | // return from step20 |
697 | 697 | if ($content['step'] == 'wizard_step20') |
@@ -700,21 +700,21 @@ discard block |
||
700 | 700 | { |
701 | 701 | case 'next': |
702 | 702 | // There's no real reason the plugin has to come from any of these, as long as it has a $steps variable |
703 | - if($this->plugin instanceof importexport_iface_import_plugin || $this->plugin instanceof importexport_wizard_basic_import_csv || strpos(get_class($this->plugin), 'import') !== false) { |
|
703 | + if ($this->plugin instanceof importexport_iface_import_plugin || $this->plugin instanceof importexport_wizard_basic_import_csv || strpos(get_class($this->plugin), 'import') !== false) { |
|
704 | 704 | $content['type'] = 'import'; |
705 | - } elseif($this->plugin instanceof importexport_iface_export_plugin || $this->plugin instanceof importexport_wizard_basic_export_csv || strpos(get_class($this->plugin),'export') !== false) { |
|
705 | + } elseif ($this->plugin instanceof importexport_iface_export_plugin || $this->plugin instanceof importexport_wizard_basic_export_csv || strpos(get_class($this->plugin), 'export') !== false) { |
|
706 | 706 | $content['type'] = 'export'; |
707 | 707 | } else { |
708 | 708 | throw new Api\Exception('Invalid plugin'); |
709 | 709 | } |
710 | - return $this->get_step($content['step'],1); |
|
710 | + return $this->get_step($content['step'], 1); |
|
711 | 711 | case 'previous' : |
712 | 712 | $readonlys['button[previous]'] = true; |
713 | - return $this->get_step($content['step'],-1); |
|
713 | + return $this->get_step($content['step'], -1); |
|
714 | 714 | case 'finish': |
715 | 715 | return 'wizard_finish'; |
716 | 716 | default : |
717 | - return $this->wizard_step20($content,$sel_options,$readonlys,$preserv); |
|
717 | + return $this->wizard_step20($content, $sel_options, $readonlys, $preserv); |
|
718 | 718 | } |
719 | 719 | } |
720 | 720 | // init step20 |
@@ -723,8 +723,8 @@ discard block |
||
723 | 723 | $content['text'] = $this->steps['wizard_step20']; |
724 | 724 | $config = Api\Config::read('phpgwapi'); |
725 | 725 | foreach ($this->plugins[$content['application']] as $type => $plugins) { |
726 | - if($config['export_limit'] == 'no' && !$GLOBALS['egw_info']['user']['apps']['admin'] && $type == 'export') continue; |
|
727 | - foreach($plugins as $plugin => $name) { |
|
726 | + if ($config['export_limit'] == 'no' && !$GLOBALS['egw_info']['user']['apps']['admin'] && $type == 'export') continue; |
|
727 | + foreach ($plugins as $plugin => $name) { |
|
728 | 728 | $sel_options['plugin'][$plugin] = $name; |
729 | 729 | } |
730 | 730 | } |
@@ -740,15 +740,15 @@ discard block |
||
740 | 740 | // name |
741 | 741 | function wizard_step21(&$content, &$sel_options, &$readonlys, &$preserv) |
742 | 742 | { |
743 | - if(self::_debug) error_log('importexport.importexport_definitions_ui::wizard_step21->$content '.print_r($content,true)); |
|
743 | + if (self::_debug) error_log('importexport.importexport_definitions_ui::wizard_step21->$content '.print_r($content, true)); |
|
744 | 744 | |
745 | 745 | // Check for duplicate name |
746 | 746 | $duplicate = isset($content['duplicate_error']); |
747 | - if($content['name'] && !$duplicate) |
|
747 | + if ($content['name'] && !$duplicate) |
|
748 | 748 | { |
749 | 749 | try { |
750 | 750 | $check_definition = new importexport_definition($content['name']); |
751 | - if($check_definition && $check_definition->definition_id && $check_definition->definition_id != $content['definition_id']) |
|
751 | + if ($check_definition && $check_definition->definition_id && $check_definition->definition_id != $content['definition_id']) |
|
752 | 752 | { |
753 | 753 | throw new Exception('Already exists'); |
754 | 754 | } |
@@ -758,21 +758,21 @@ discard block |
||
758 | 758 | |
759 | 759 | // Try some suggestions |
760 | 760 | $suggestions = array( |
761 | - $content['name'] .'-'. $GLOBALS['egw_info']['user']['account_lid'], |
|
762 | - $content['name'] .'-'. $GLOBALS['egw_info']['user']['account_id'], |
|
763 | - $content['name'] .'-'. Api\DateTime::to('now', true), |
|
761 | + $content['name'].'-'.$GLOBALS['egw_info']['user']['account_lid'], |
|
762 | + $content['name'].'-'.$GLOBALS['egw_info']['user']['account_id'], |
|
763 | + $content['name'].'-'.Api\DateTime::to('now', true), |
|
764 | 764 | //$content['name'] .'-'. rand(0,100), |
765 | 765 | ); |
766 | - foreach($suggestions as $key => $suggestion) { |
|
766 | + foreach ($suggestions as $key => $suggestion) { |
|
767 | 767 | $sug_definition = new importexport_definition($suggestion); |
768 | - if($sug_definition->definition_id) { |
|
768 | + if ($sug_definition->definition_id) { |
|
769 | 769 | unset($suggestions[$key]); |
770 | 770 | } |
771 | 771 | } |
772 | - if($suggestions) { |
|
773 | - $content['duplicate_error'] .= ' '. lang('Try')." \n" . implode("\n", $suggestions); |
|
772 | + if ($suggestions) { |
|
773 | + $content['duplicate_error'] .= ' '.lang('Try')." \n".implode("\n", $suggestions); |
|
774 | 774 | } |
775 | - return $this->get_step($content['step'],0); |
|
775 | + return $this->get_step($content['step'], 0); |
|
776 | 776 | } |
777 | 777 | } |
778 | 778 | |
@@ -782,19 +782,19 @@ discard block |
||
782 | 782 | switch (array_search('pressed', $content['button'])) |
783 | 783 | { |
784 | 784 | case 'next': |
785 | - return $this->get_step($content['step'],1); |
|
785 | + return $this->get_step($content['step'], 1); |
|
786 | 786 | case 'previous' : |
787 | - return $this->get_step($content['step'],-1); |
|
787 | + return $this->get_step($content['step'], -1); |
|
788 | 788 | case 'finish': |
789 | 789 | return 'wizard_finish'; |
790 | 790 | default : |
791 | - return $this->wizard_step21($content,$sel_options,$readonlys,$preserv); |
|
791 | + return $this->wizard_step21($content, $sel_options, $readonlys, $preserv); |
|
792 | 792 | } |
793 | 793 | } |
794 | 794 | // init step21 |
795 | 795 | else |
796 | 796 | { |
797 | - $content['text'] = $this->steps['wizard_step21'] . ($duplicate ? "\n".$content['duplicate_error'] : ''); |
|
797 | + $content['text'] = $this->steps['wizard_step21'].($duplicate ? "\n".$content['duplicate_error'] : ''); |
|
798 | 798 | $content['step'] = 'wizard_step21'; |
799 | 799 | unset($content['duplicate_error']); |
800 | 800 | $preserv = $content; |
@@ -806,17 +806,16 @@ discard block |
||
806 | 806 | // allowed users |
807 | 807 | function wizard_step90(&$content, &$sel_options, &$readonlys, &$preserv) |
808 | 808 | { |
809 | - if(self::_debug) error_log('importexport.importexport_definitions_ui::wizard_step90->$content '.print_r($content,true)); |
|
809 | + if (self::_debug) error_log('importexport.importexport_definitions_ui::wizard_step90->$content '.print_r($content, true)); |
|
810 | 810 | |
811 | 811 | // return from step90 |
812 | 812 | if ($content['step'] == 'wizard_step90') |
813 | 813 | { |
814 | - if($this->can_edit($content)) |
|
814 | + if ($this->can_edit($content)) |
|
815 | 815 | { |
816 | - $content['owner'] = $content['just_me'] || !$GLOBALS['egw']->acl->check('share_definitions', Acl::READ,'importexport') ? |
|
817 | - ($content['owner'] ? $content['owner'] : $GLOBALS['egw_info']['user']['account_id']) : |
|
818 | - null; |
|
819 | - $content['allowed_users'] = $content['just_me'] ? '' : ($content['all_users'] ? 'all' : implode(',',$content['allowed_users'])); |
|
816 | + $content['owner'] = $content['just_me'] || !$GLOBALS['egw']->acl->check('share_definitions', Acl::READ, 'importexport') ? |
|
817 | + ($content['owner'] ? $content['owner'] : $GLOBALS['egw_info']['user']['account_id']) : null; |
|
818 | + $content['allowed_users'] = $content['just_me'] ? '' : ($content['all_users'] ? 'all' : implode(',', $content['allowed_users'])); |
|
820 | 819 | unset($content['just_me']); |
821 | 820 | } |
822 | 821 | |
@@ -824,12 +823,12 @@ discard block |
||
824 | 823 | switch (array_search('pressed', $content['button'])) |
825 | 824 | { |
826 | 825 | case 'previous' : |
827 | - return $this->get_step($content['step'],-1); |
|
826 | + return $this->get_step($content['step'], -1); |
|
828 | 827 | case 'next': |
829 | 828 | case 'finish': |
830 | 829 | return 'wizard_finish'; |
831 | 830 | default : |
832 | - return $this->wizard_step90($content,$sel_options,$readonlys,$preserv); |
|
831 | + return $this->wizard_step90($content, $sel_options, $readonlys, $preserv); |
|
833 | 832 | } |
834 | 833 | } |
835 | 834 | // init step90 |
@@ -840,10 +839,10 @@ discard block |
||
840 | 839 | $preserv = $content; |
841 | 840 | |
842 | 841 | // Set owner for non-admins |
843 | - $content['just_me'] = ((!$content['allowed_users'] || !$content['allowed_users'][0] && count($content['allowed_users']) ==1) && $content['owner']); |
|
844 | - $content['all_users'] = is_array($content['allowed_users']) && array_key_exists('0',$content['allowed_users']) && $content['allowed_users'][0] == 'all' || |
|
842 | + $content['just_me'] = ((!$content['allowed_users'] || !$content['allowed_users'][0] && count($content['allowed_users']) == 1) && $content['owner']); |
|
843 | + $content['all_users'] = is_array($content['allowed_users']) && array_key_exists('0', $content['allowed_users']) && $content['allowed_users'][0] == 'all' || |
|
845 | 844 | $content['allowed_users'] == 'all'; |
846 | - if(!$GLOBALS['egw']->acl->check('share_definition', Acl::READ, 'importexport') && !$GLOBALS['egw_info']['user']['apps']['admin']) |
|
845 | + if (!$GLOBALS['egw']->acl->check('share_definition', Acl::READ, 'importexport') && !$GLOBALS['egw_info']['user']['apps']['admin']) |
|
847 | 846 | { |
848 | 847 | $content['allowed_users'] = array(); |
849 | 848 | $readonlys['allowed_users'] = true; |
@@ -859,11 +858,11 @@ discard block |
||
859 | 858 | ) |
860 | 859 | ); |
861 | 860 | // Hide 'just me' checkbox, users get confused by read-only |
862 | - if($readonlys['just_me'] || !$this->can_edit($content)) |
|
861 | + if ($readonlys['just_me'] || !$this->can_edit($content)) |
|
863 | 862 | { |
864 | 863 | $content['no_just_me'] = true; |
865 | 864 | } |
866 | - if($readonlys['all_users'] || !$this->can_edit($content)) |
|
865 | + if ($readonlys['all_users'] || !$this->can_edit($content)) |
|
867 | 866 | { |
868 | 867 | $content['no_all_users'] = true; |
869 | 868 | } |
@@ -876,7 +875,7 @@ discard block |
||
876 | 875 | |
877 | 876 | function wizard_finish(&$content) |
878 | 877 | { |
879 | - if(self::_debug) error_log('importexport.importexport_definitions_ui::wizard_finish->$content '.print_r($content,true)); |
|
878 | + if (self::_debug) error_log('importexport.importexport_definitions_ui::wizard_finish->$content '.print_r($content, true)); |
|
880 | 879 | // Take out some UI leavings |
881 | 880 | unset($content['text']); |
882 | 881 | unset($content['step']); |
@@ -886,26 +885,26 @@ discard block |
||
886 | 885 | $bodefinitions->save($content); |
887 | 886 | // This message is displayed if browser cant close window |
888 | 887 | $content['msg'] = lang('ImportExport wizard finished successfully!'); |
889 | - Framework::refresh_opener('','importexport'); |
|
888 | + Framework::refresh_opener('', 'importexport'); |
|
890 | 889 | Framework::window_close(); |
891 | 890 | return 'importexport.wizard_close'; |
892 | 891 | } |
893 | 892 | |
894 | - function import_definition($content='') |
|
893 | + function import_definition($content = '') |
|
895 | 894 | { |
896 | 895 | $bodefinitions = new importexport_definitions_bo(); |
897 | 896 | if (is_array($content)) |
898 | 897 | { |
899 | - if($content['import_file']['tmp_name']) |
|
898 | + if ($content['import_file']['tmp_name']) |
|
900 | 899 | { |
901 | 900 | $result = $bodefinitions->import($content['import_file']['tmp_name']); |
902 | - $msg = lang('%1 definitions %2', count($result), lang('imported')) ."\n". implode("\n", array_keys($result)); |
|
901 | + $msg = lang('%1 definitions %2', count($result), lang('imported'))."\n".implode("\n", array_keys($result)); |
|
903 | 902 | return $this->index(null, $msg); |
904 | 903 | } |
905 | - if($content['update']) |
|
904 | + if ($content['update']) |
|
906 | 905 | { |
907 | 906 | $applist = importexport_helper_functions::get_apps('all', true); |
908 | - foreach($applist as $appname) { |
|
907 | + foreach ($applist as $appname) { |
|
909 | 908 | importexport_helper_functions::load_defaults($appname); |
910 | 909 | } |
911 | 910 | return $this->index(); |
@@ -915,7 +914,7 @@ discard block |
||
915 | 914 | { |
916 | 915 | $content = array(); |
917 | 916 | $etpl = new etemplate(self::_appname.'.import_definition'); |
918 | - return $etpl->exec(self::_appname.'.importexport_definitions_ui.import_definition',$content,array(),$readonlys,$preserv); |
|
917 | + return $etpl->exec(self::_appname.'.importexport_definitions_ui.import_definition', $content, array(), $readonlys, $preserv); |
|
919 | 918 | } |
920 | 919 | } |
921 | 920 | |
@@ -925,17 +924,17 @@ discard block |
||
925 | 924 | */ |
926 | 925 | protected function can_edit(Array $definition) |
927 | 926 | { |
928 | - if($definition['owner'] && $definition['owner'] == $GLOBALS['egw_info']['user']['account_id']) |
|
927 | + if ($definition['owner'] && $definition['owner'] == $GLOBALS['egw_info']['user']['account_id']) |
|
929 | 928 | { |
930 | 929 | // Definition belongs to user |
931 | 930 | return true; |
932 | 931 | } |
933 | - elseif($definition['definition_id'] && !$definition['owner'] && $GLOBALS['egw_info']['user']['apps']['admin']) |
|
932 | + elseif ($definition['definition_id'] && !$definition['owner'] && $GLOBALS['egw_info']['user']['apps']['admin']) |
|
934 | 933 | { |
935 | 934 | // Definition is unowned, and user is an admin |
936 | 935 | return true; |
937 | 936 | } |
938 | - elseif(!$definition['definition_id']) |
|
937 | + elseif (!$definition['definition_id']) |
|
939 | 938 | { |
940 | 939 | // Definition is in-progress, not saved yet |
941 | 940 | return true; |
@@ -948,26 +947,26 @@ discard block |
||
948 | 947 | */ |
949 | 948 | public function site_config($content = array()) |
950 | 949 | { |
951 | - if(!$GLOBALS['egw_info']['user']['apps']['admin']) |
|
950 | + if (!$GLOBALS['egw_info']['user']['apps']['admin']) |
|
952 | 951 | { |
953 | 952 | Egw::redirect_link('/home'); |
954 | 953 | } |
955 | - if($content['save']) |
|
954 | + if ($content['save']) |
|
956 | 955 | { |
957 | 956 | unset($content['save']); |
958 | 957 | |
959 | 958 | // ACL |
960 | - $GLOBALS['egw']->acl->delete_repository(self::_appname, 'definition',false); |
|
961 | - $GLOBALS['egw']->acl->delete_repository(self::_appname, 'share_definition',false); |
|
959 | + $GLOBALS['egw']->acl->delete_repository(self::_appname, 'definition', false); |
|
960 | + $GLOBALS['egw']->acl->delete_repository(self::_appname, 'share_definition', false); |
|
962 | 961 | |
963 | - foreach($content['share_definition'] as $group) |
|
962 | + foreach ($content['share_definition'] as $group) |
|
964 | 963 | { |
965 | - $GLOBALS['egw']->acl->add_repository(self::_appname, 'share_definition', $group,Acl::READ); |
|
964 | + $GLOBALS['egw']->acl->add_repository(self::_appname, 'share_definition', $group, Acl::READ); |
|
966 | 965 | } |
967 | 966 | unset($content['share_definition']); |
968 | 967 | |
969 | 968 | // Other Api\Config |
970 | - foreach($content as $key=>$value) |
|
969 | + foreach ($content as $key=>$value) |
|
971 | 970 | { |
972 | 971 | Api\Config::save_value($key, $value, 'importexport'); |
973 | 972 | } |
@@ -977,18 +976,18 @@ discard block |
||
977 | 976 | |
978 | 977 | $data = Api\Config::read(self::_appname); |
979 | 978 | $data['share_definition'] = $GLOBALS['egw']->acl->get_ids_for_location('share_definition', Acl::READ, self::_appname); |
980 | - $sel_options['import_charsets'] = array_combine(mb_list_encodings(),mb_list_encodings()); |
|
979 | + $sel_options['import_charsets'] = array_combine(mb_list_encodings(), mb_list_encodings()); |
|
981 | 980 | |
982 | 981 | // Remove 'standard' encodings to prevent doubles |
983 | - foreach(Api\Translation::get_installed_charsets() as $charset => $label) |
|
982 | + foreach (Api\Translation::get_installed_charsets() as $charset => $label) |
|
984 | 983 | { |
985 | 984 | unset($sel_options['import_charsets'][strtoupper($charset)]); |
986 | 985 | } |
987 | 986 | |
988 | - if(!$data['update']) $data['update'] = 'request'; |
|
987 | + if (!$data['update']) $data['update'] = 'request'; |
|
989 | 988 | |
990 | - $GLOBALS['egw_info']['flags']['app_header'] = lang('Site configuration') . ' - ' . lang(self::_appname); |
|
989 | + $GLOBALS['egw_info']['flags']['app_header'] = lang('Site configuration').' - '.lang(self::_appname); |
|
991 | 990 | $etpl = new etemplate(self::_appname.'.config'); |
992 | - $etpl->exec(self::_appname.'.importexport_definitions_ui.site_config',$data,$sel_options,$readonlys,$preserv); |
|
991 | + $etpl->exec(self::_appname.'.importexport_definitions_ui.site_config', $data, $sel_options, $readonlys, $preserv); |
|
993 | 992 | } |
994 | 993 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * |
97 | 97 | * @param stram $_stream resource where records are exported to. |
98 | 98 | * @param array _options options for specific backends |
99 | - * @return bool |
|
99 | + * @return boolean|null |
|
100 | 100 | */ |
101 | 101 | public function __construct( $_stream, array $_options ) { |
102 | 102 | if (!is_object($GLOBALS['egw']->translation)) { |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * exports a record into resource of handle |
152 | 152 | * |
153 | 153 | * @param importexport_iface_egw_record record |
154 | - * @return bool |
|
154 | + * @return boolean|null |
|
155 | 155 | */ |
156 | 156 | public function export_record( importexport_iface_egw_record $_record ) { |
157 | 157 | $this->record = $_record; |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | * |
285 | 285 | * Uses the static variable $types to convert various datatypes. |
286 | 286 | * |
287 | - * @param record Record to be converted |
|
287 | + * @param record importexport_iface_egw_record to be converted |
|
288 | 288 | * @parem fields List of field types => field names to be converted |
289 | 289 | * @param appname Current appname if you want to do custom fields too |
290 | 290 | */ |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | * @parem fields List of field types => field names to be converted |
289 | 289 | * @param appname Current appname if you want to do custom fields too |
290 | 290 | */ |
291 | - public static function convert(importexport_iface_egw_record &$record, Array $fields = array(), $appname = null, $selects = array()) { |
|
291 | + public static function convert(importexport_iface_egw_record &$record, array $fields = array(), $appname = null, $selects = array()) { |
|
292 | 292 | if($appname) { |
293 | 293 | if(!self::$cf_parse_cache[$appname]) { |
294 | 294 | $c_fields = self::convert_parse_custom_fields($appname, $selects, $links, $methods); |
@@ -452,7 +452,7 @@ discard block |
||
452 | 452 | * @param char $delimiter |
453 | 453 | * @param char $enclosure |
454 | 454 | */ |
455 | - protected function fputcsv($filePointer, Array $dataArray, $delimiter, $enclosure){ |
|
455 | + protected function fputcsv($filePointer, array $dataArray, $delimiter, $enclosure){ |
|
456 | 456 | $string = ""; |
457 | 457 | $writeDelimiter = false; |
458 | 458 | foreach($dataArray as $dataElement) { |
@@ -98,22 +98,32 @@ discard block |
||
98 | 98 | * @param array _options options for specific backends |
99 | 99 | * @return bool |
100 | 100 | */ |
101 | - public function __construct( $_stream, array $_options ) { |
|
102 | - if (!is_object($GLOBALS['egw']->translation)) { |
|
101 | + public function __construct( $_stream, array $_options ) |
|
102 | + { |
|
103 | + if (!is_object($GLOBALS['egw']->translation)) |
|
104 | + { |
|
103 | 105 | $GLOBALS['egw']->translation = new Api\Translation(); |
104 | 106 | } |
105 | 107 | $this->translation = &$GLOBALS['egw']->translation; |
106 | 108 | $this->handle = $_stream; |
107 | - if($_options['charset'] == 'user') $_options['charset'] = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset']; |
|
109 | + if($_options['charset'] == 'user') |
|
110 | + { |
|
111 | + $_options['charset'] = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset']; |
|
112 | + } |
|
108 | 113 | $this->csv_charset = $_options['charset'] ? $_options['charset'] : 'utf-8'; |
109 | - if ( !empty( $_options ) ) { |
|
114 | + if ( !empty( $_options ) ) |
|
115 | + { |
|
110 | 116 | $this->csv_options = array_merge( $this->csv_options, $_options ); |
111 | 117 | } |
112 | 118 | //error_log(__METHOD__.__LINE__.array2string($_options['appname'])); |
113 | - if(!Api\Storage\Merge::is_export_limit_excepted()) { |
|
119 | + if(!Api\Storage\Merge::is_export_limit_excepted()) |
|
120 | + { |
|
114 | 121 | $this->export_limit = Api\Storage\Merge::getExportLimit($_options['appname']); |
115 | 122 | //error_log(__METHOD__.__LINE__.' app:'.$_options['appname'].' limit:'.$this->export_limit); |
116 | - if($this->export_limit == 'no') throw new Api\Exception\NoPermission\Admin('Export disabled'); |
|
123 | + if($this->export_limit == 'no') |
|
124 | + { |
|
125 | + throw new Api\Exception\NoPermission\Admin('Export disabled'); |
|
126 | + } |
|
117 | 127 | } |
118 | 128 | } |
119 | 129 | |
@@ -122,15 +132,19 @@ discard block |
||
122 | 132 | * |
123 | 133 | * @param array $_mapping egw_field_name => csv_field_name |
124 | 134 | */ |
125 | - public function set_mapping( array &$_mapping) { |
|
126 | - if ($this->num_of_records > 0) { |
|
135 | + public function set_mapping( array &$_mapping) |
|
136 | + { |
|
137 | + if ($this->num_of_records > 0) |
|
138 | + { |
|
127 | 139 | throw new Exception('Error: Field mapping can\'t be set during ongoing export!'); |
128 | 140 | } |
129 | - if($_mapping['all_custom_fields']) { |
|
141 | + if($_mapping['all_custom_fields']) |
|
142 | + { |
|
130 | 143 | // Field value is the appname, so we can pull the fields |
131 | 144 | $custom = Api\Storage\Customfields::get($_mapping['all_custom_fields']); |
132 | 145 | unset($_mapping['all_custom_fields']); |
133 | - foreach($custom as $field => $info) { |
|
146 | + foreach($custom as $field => $info) |
|
147 | + { |
|
134 | 148 | $_mapping['#'.$field] = $this->csv_options['begin_with_fieldnames'] == 'label' ? $info['label'] : $field; |
135 | 149 | } |
136 | 150 | } |
@@ -143,7 +157,8 @@ discard block |
||
143 | 157 | * |
144 | 158 | * @param array $_conversion |
145 | 159 | */ |
146 | - public function set_conversion( array $_conversion) { |
|
160 | + public function set_conversion( array $_conversion) |
|
161 | + { |
|
147 | 162 | $this->conversion = $_conversion; |
148 | 163 | } |
149 | 164 | |
@@ -153,16 +168,23 @@ discard block |
||
153 | 168 | * @param importexport_iface_egw_record record |
154 | 169 | * @return bool |
155 | 170 | */ |
156 | - public function export_record( importexport_iface_egw_record $_record ) { |
|
171 | + public function export_record( importexport_iface_egw_record $_record ) |
|
172 | + { |
|
157 | 173 | $this->record = $_record; |
158 | 174 | $this->record_array = $_record->get_record_array(); |
159 | 175 | |
160 | 176 | // begin with fieldnames ? |
161 | - if ($this->num_of_records == 0 && $this->csv_options['begin_with_fieldnames'] ) { |
|
162 | - if($this->csv_options['begin_with_fieldnames'] == 'label') { |
|
177 | + if ($this->num_of_records == 0 && $this->csv_options['begin_with_fieldnames'] ) |
|
178 | + { |
|
179 | + if($this->csv_options['begin_with_fieldnames'] == 'label') |
|
180 | + { |
|
163 | 181 | // Load translations for app |
164 | 182 | list($appname, $part2) = explode('_', get_class($_record)); |
165 | - if(!$GLOBALS['egw_info']['apps'][$appname]) $appname .= $part2; // Handle apps with _ in the name |
|
183 | + if(!$GLOBALS['egw_info']['apps'][$appname]) |
|
184 | + { |
|
185 | + $appname .= $part2; |
|
186 | + } |
|
187 | + // Handle apps with _ in the name |
|
166 | 188 | |
167 | 189 | // Get translations from wizard, if possible |
168 | 190 | if(!$this->csv_options['no_header_translation']) |
@@ -180,11 +202,16 @@ discard block |
||
180 | 202 | $label = $label != $fields[$field] ? $fields[$field] : lang($label); |
181 | 203 | } |
182 | 204 | // Make sure no * |
183 | - if(substr($label,-1) == '*') $label = substr($label,0,-1); |
|
205 | + if(substr($label,-1) == '*') |
|
206 | + { |
|
207 | + $label = substr($label,0,-1); |
|
208 | + } |
|
184 | 209 | } |
185 | - } catch (Exception $e) { |
|
210 | + } |
|
211 | + catch (Exception $e) { |
|
186 | 212 | Api\Translation::add_app($appname); |
187 | - foreach($this->mapping as $field => &$label) { |
|
213 | + foreach($this->mapping as $field => &$label) |
|
214 | + { |
|
188 | 215 | $label = lang($label); |
189 | 216 | } |
190 | 217 | } |
@@ -195,20 +222,24 @@ discard block |
||
195 | 222 | } |
196 | 223 | |
197 | 224 | // Check for limit |
198 | - if($this->export_limit && $this->num_of_records >= $this->export_limit) { |
|
225 | + if($this->export_limit && $this->num_of_records >= $this->export_limit) |
|
226 | + { |
|
199 | 227 | return; |
200 | 228 | } |
201 | 229 | |
202 | 230 | // do conversions |
203 | - if ( !empty( $this->conversion )) { |
|
231 | + if ( !empty( $this->conversion )) |
|
232 | + { |
|
204 | 233 | $this->record_array = importexport_helper_functions::conversion( $this->record_array, $this->conversion ); |
205 | 234 | } |
206 | 235 | |
207 | 236 | // do fieldmapping |
208 | - if ( !empty( $this->mapping ) ) { |
|
237 | + if ( !empty( $this->mapping ) ) |
|
238 | + { |
|
209 | 239 | $record_data = $this->record_array; |
210 | 240 | $this->record_array = array(); |
211 | - foreach ($this->mapping as $egw_field => $csv_field) { |
|
241 | + foreach ($this->mapping as $egw_field => $csv_field) |
|
242 | + { |
|
212 | 243 | $this->record_array[$csv_field] = $record_data[$egw_field]; |
213 | 244 | } |
214 | 245 | } |
@@ -222,7 +253,8 @@ discard block |
||
222 | 253 | * |
223 | 254 | * @return int |
224 | 255 | */ |
225 | - public function get_num_of_records() { |
|
256 | + public function get_num_of_records() |
|
257 | + { |
|
226 | 258 | return $this->num_of_records; |
227 | 259 | } |
228 | 260 | |
@@ -236,14 +268,20 @@ discard block |
||
236 | 268 | * |
237 | 269 | * @return Array of fields to be added to list of fields needing conversion |
238 | 270 | */ |
239 | - public static function convert_parse_custom_fields($appname, &$selects = array(), &$links = array(), &$methods = array()) { |
|
240 | - if(!$appname) return; |
|
271 | + public static function convert_parse_custom_fields($appname, &$selects = array(), &$links = array(), &$methods = array()) |
|
272 | + { |
|
273 | + if(!$appname) |
|
274 | + { |
|
275 | + return; |
|
276 | + } |
|
241 | 277 | |
242 | 278 | $fields = array(); |
243 | 279 | $custom = Api\Storage\Customfields::get($appname); |
244 | - foreach($custom as $name => $c_field) { |
|
280 | + foreach($custom as $name => $c_field) |
|
281 | + { |
|
245 | 282 | $name = '#' . $name; |
246 | - switch($c_field['type']) { |
|
283 | + switch($c_field['type']) |
|
284 | + { |
|
247 | 285 | case 'date': |
248 | 286 | $fields['date'][] = $name; |
249 | 287 | break; |
@@ -254,7 +292,8 @@ discard block |
||
254 | 292 | $fields['select-account'][] = $name; |
255 | 293 | break; |
256 | 294 | case 'ajax_select': |
257 | - if($c_field['values']['get_title']) { |
|
295 | + if($c_field['values']['get_title']) |
|
296 | + { |
|
258 | 297 | $methods[$name] = $c_field['values']['get_title']; |
259 | 298 | break; |
260 | 299 | } |
@@ -269,7 +308,8 @@ discard block |
||
269 | 308 | break; |
270 | 309 | default: |
271 | 310 | list($type) = explode('-',$c_field['type'],2); |
272 | - if(in_array($type, array_keys($GLOBALS['egw_info']['apps']))) { |
|
311 | + if(in_array($type, array_keys($GLOBALS['egw_info']['apps']))) |
|
312 | + { |
|
273 | 313 | $fields['links'][] = $name; |
274 | 314 | $links[$name] = $c_field['type']; |
275 | 315 | } |
@@ -288,9 +328,12 @@ discard block |
||
288 | 328 | * @parem fields List of field types => field names to be converted |
289 | 329 | * @param appname Current appname if you want to do custom fields too |
290 | 330 | */ |
291 | - public static function convert(importexport_iface_egw_record &$record, Array $fields = array(), $appname = null, $selects = array()) { |
|
292 | - if($appname) { |
|
293 | - if(!self::$cf_parse_cache[$appname]) { |
|
331 | + public static function convert(importexport_iface_egw_record &$record, Array $fields = array(), $appname = null, $selects = array()) |
|
332 | + { |
|
333 | + if($appname) |
|
334 | + { |
|
335 | + if(!self::$cf_parse_cache[$appname]) |
|
336 | + { |
|
294 | 337 | $c_fields = self::convert_parse_custom_fields($appname, $selects, $links, $methods); |
295 | 338 | self::$cf_parse_cache[$appname] = array($c_fields, $selects, $links, $methods); |
296 | 339 | } |
@@ -299,7 +342,10 @@ discard block |
||
299 | 342 | // Add in any fields that are keys to another app |
300 | 343 | foreach((array)$fields['links'] as $link_field => $app) |
301 | 344 | { |
302 | - if(is_numeric($link_field)) continue; |
|
345 | + if(is_numeric($link_field)) |
|
346 | + { |
|
347 | + continue; |
|
348 | + } |
|
303 | 349 | $links[$link_field] = $app; |
304 | 350 | // Set it as a normal link field |
305 | 351 | $fields['links'][] = $link_field; |
@@ -307,8 +353,10 @@ discard block |
||
307 | 353 | } |
308 | 354 | |
309 | 355 | // Not quite a recursive merge, since only one level |
310 | - foreach($fields as $type => &$list) { |
|
311 | - if($c_fields[$type]) { |
|
356 | + foreach($fields as $type => &$list) |
|
357 | + { |
|
358 | + if($c_fields[$type]) |
|
359 | + { |
|
312 | 360 | $list = array_merge($c_fields[$type], $list); |
313 | 361 | unset($c_fields[$type]); |
314 | 362 | } |
@@ -316,16 +364,22 @@ discard block |
||
316 | 364 | $fields += $c_fields; |
317 | 365 | $selects += $c_selects; |
318 | 366 | } |
319 | - foreach((array)$fields['select'] as $name) { |
|
320 | - if($record->$name != null && is_array($selects) && $selects[$name]) { |
|
367 | + foreach((array)$fields['select'] as $name) |
|
368 | + { |
|
369 | + if($record->$name != null && is_array($selects) && $selects[$name]) |
|
370 | + { |
|
321 | 371 | $record->$name = is_string($record->$name) ? explode(',', $record->$name) : $record->$name; |
322 | - if(is_array($record->$name)) { |
|
372 | + if(is_array($record->$name)) |
|
373 | + { |
|
323 | 374 | $names = array(); |
324 | - foreach($record->$name as $_name) { |
|
375 | + foreach($record->$name as $_name) |
|
376 | + { |
|
325 | 377 | $names[] = lang($selects[$name][$_name]); |
326 | 378 | } |
327 | 379 | $record->$name = implode(', ', $names); |
328 | - } else { |
|
380 | + } |
|
381 | + else |
|
382 | + { |
|
329 | 383 | $record->$name = lang($selects[$name][$record->$name]); |
330 | 384 | } |
331 | 385 | } |
@@ -334,9 +388,12 @@ discard block |
||
334 | 388 | $record->$name = ''; |
335 | 389 | } |
336 | 390 | } |
337 | - foreach((array)$fields['links'] as $name) { |
|
338 | - if($record->$name) { |
|
339 | - if(is_numeric($record->$name) && !$links[$name]) { |
|
391 | + foreach((array)$fields['links'] as $name) |
|
392 | + { |
|
393 | + if($record->$name) |
|
394 | + { |
|
395 | + if(is_numeric($record->$name) && !$links[$name]) |
|
396 | + { |
|
340 | 397 | $link = Link::get_link($record->$name); |
341 | 398 | $links[$name] = ($link['link_app1'] == $appname ? $link['link_app2'] : $link['link_app1']); |
342 | 399 | $record->$name = ($link['link_app1'] == $appname ? $link['link_id2'] : $link['link_id1']); |
@@ -355,16 +412,22 @@ discard block |
||
355 | 412 | $record->$name = ''; |
356 | 413 | } |
357 | 414 | } |
358 | - foreach((array)$fields['select-account'] as $name) { |
|
415 | + foreach((array)$fields['select-account'] as $name) |
|
416 | + { |
|
359 | 417 | // Compare against null to deal with empty arrays |
360 | - if ($record->$name !== null) { |
|
361 | - if(is_array($record->$name)) { |
|
418 | + if ($record->$name !== null) |
|
419 | + { |
|
420 | + if(is_array($record->$name)) |
|
421 | + { |
|
362 | 422 | $names = array(); |
363 | - foreach($record->$name as $_name) { |
|
423 | + foreach($record->$name as $_name) |
|
424 | + { |
|
364 | 425 | $names[] = Api\Accounts::username($_name); |
365 | 426 | } |
366 | 427 | $record->$name = implode(', ', $names); |
367 | - } else { |
|
428 | + } |
|
429 | + else |
|
430 | + { |
|
368 | 431 | $record->$name = Api\Accounts::username($record->$name); |
369 | 432 | } |
370 | 433 | } |
@@ -373,23 +436,49 @@ discard block |
||
373 | 436 | $record->$name = ''; |
374 | 437 | } |
375 | 438 | } |
376 | - foreach((array)$fields['select-bool'] as $name) { |
|
377 | - if($record->$name !== null) { |
|
439 | + foreach((array)$fields['select-bool'] as $name) |
|
440 | + { |
|
441 | + if($record->$name !== null) |
|
442 | + { |
|
378 | 443 | $record->$name = $record->$name ? lang('Yes') : lang('No'); |
379 | 444 | } |
380 | 445 | } |
381 | - foreach((array)$fields['date-time'] as $name) { |
|
446 | + foreach((array)$fields['date-time'] as $name) |
|
447 | + { |
|
382 | 448 | //if ($record->$name) $record->$name = date('Y-m-d H:i:s',$record->$name); // Standard date format |
383 | - if ($record->$name && !is_numeric($record->$name)) $record->$name = strtotime($record->$name); // Custom fields stored as string |
|
384 | - if ($record->$name && is_numeric($record->$name)) $record->$name = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'] . ' '. |
|
385 | - ($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == '24' ? 'H:i:s' : 'h:i:s a'),$record->$name); // User date format |
|
386 | - if (!$record->$name) $record->$name = ''; |
|
449 | + if ($record->$name && !is_numeric($record->$name)) |
|
450 | + { |
|
451 | + $record->$name = strtotime($record->$name); |
|
452 | + } |
|
453 | + // Custom fields stored as string |
|
454 | + if ($record->$name && is_numeric($record->$name)) |
|
455 | + { |
|
456 | + $record->$name = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'] . ' '. |
|
457 | + ($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == '24' ? 'H:i:s' : 'h:i:s a'),$record->$name); |
|
458 | + } |
|
459 | + // User date format |
|
460 | + if (!$record->$name) |
|
461 | + { |
|
462 | + $record->$name = ''; |
|
463 | + } |
|
387 | 464 | } |
388 | - foreach((array)$fields['date'] as $name) { |
|
465 | + foreach((array)$fields['date'] as $name) |
|
466 | + { |
|
389 | 467 | //if ($record->$name) $record->$name = date('Y-m-d',$record->$name); // Standard date format |
390 | - if ($record->$name && !is_numeric($record->$name)) $record->$name = strtotime($record->$name); // Custom fields stored as string |
|
391 | - if ($record->$name && is_numeric($record->$name)) $record->$name = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], $record->$name); // User date format |
|
392 | - if (!$record->$name) $record->$name = ''; |
|
468 | + if ($record->$name && !is_numeric($record->$name)) |
|
469 | + { |
|
470 | + $record->$name = strtotime($record->$name); |
|
471 | + } |
|
472 | + // Custom fields stored as string |
|
473 | + if ($record->$name && is_numeric($record->$name)) |
|
474 | + { |
|
475 | + $record->$name = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], $record->$name); |
|
476 | + } |
|
477 | + // User date format |
|
478 | + if (!$record->$name) |
|
479 | + { |
|
480 | + $record->$name = ''; |
|
481 | + } |
|
393 | 482 | } |
394 | 483 | foreach((array)$fields['float'] as $name) |
395 | 484 | { |
@@ -397,7 +486,10 @@ discard block |
||
397 | 486 | if (is_null($dec_separator)) |
398 | 487 | { |
399 | 488 | $dec_separator = $GLOBALS['egw_info']['user']['preferences']['common']['number_format'][0]; |
400 | - if (empty($dec_separator)) $dec_separator = '.'; |
|
489 | + if (empty($dec_separator)) |
|
490 | + { |
|
491 | + $dec_separator = '.'; |
|
492 | + } |
|
401 | 493 | $thousands_separator = $GLOBALS['egw_info']['user']['preferences']['common']['number_format'][1]; |
402 | 494 | } |
403 | 495 | if($record->$name && (string)$record->$name != '') |
@@ -413,17 +505,27 @@ discard block |
||
413 | 505 | } |
414 | 506 | |
415 | 507 | // Some custom methods for conversion |
416 | - foreach((array)$methods as $name => $method) { |
|
417 | - if($record->$name) $record->$name = ExecMethod($method, $record->$name); |
|
508 | + foreach((array)$methods as $name => $method) |
|
509 | + { |
|
510 | + if($record->$name) |
|
511 | + { |
|
512 | + $record->$name = ExecMethod($method, $record->$name); |
|
513 | + } |
|
418 | 514 | } |
419 | 515 | |
420 | 516 | static $cat_object; |
421 | - if(is_null($cat_object)) $cat_object = new Api\Categories(false,$appname); |
|
422 | - foreach((array)$fields['select-cat'] as $name) { |
|
423 | - if($record->$name) { |
|
517 | + if(is_null($cat_object)) |
|
518 | + { |
|
519 | + $cat_object = new Api\Categories(false,$appname); |
|
520 | + } |
|
521 | + foreach((array)$fields['select-cat'] as $name) |
|
522 | + { |
|
523 | + if($record->$name) |
|
524 | + { |
|
424 | 525 | $cats = array(); |
425 | 526 | $ids = is_array($record->$name) ? $record->$name : explode(',', $record->$name); |
426 | - foreach($ids as $n => $cat_id) { |
|
527 | + foreach($ids as $n => $cat_id) |
|
528 | + { |
|
427 | 529 | |
428 | 530 | if ($cat_id && $cat_object->check_perms(Acl::READ,$cat_id)) |
429 | 531 | { |
@@ -444,7 +546,8 @@ discard block |
||
444 | 546 | * |
445 | 547 | * @return |
446 | 548 | */ |
447 | - public function __destruct() { |
|
549 | + public function __destruct() |
|
550 | + { |
|
448 | 551 | |
449 | 552 | } |
450 | 553 | |
@@ -457,11 +560,16 @@ discard block |
||
457 | 560 | * @param char $delimiter |
458 | 561 | * @param char $enclosure |
459 | 562 | */ |
460 | - protected function fputcsv($filePointer, Array $dataArray, $delimiter, $enclosure){ |
|
563 | + protected function fputcsv($filePointer, Array $dataArray, $delimiter, $enclosure) |
|
564 | + { |
|
461 | 565 | $string = ""; |
462 | 566 | $writeDelimiter = false; |
463 | - foreach($dataArray as $dataElement) { |
|
464 | - if($writeDelimiter) $string .= $delimiter; |
|
567 | + foreach($dataArray as $dataElement) |
|
568 | + { |
|
569 | + if($writeDelimiter) |
|
570 | + { |
|
571 | + $string .= $delimiter; |
|
572 | + } |
|
465 | 573 | $string .= $enclosure . str_replace(array("\r\n", '"'), array("\n",'""'), $dataElement) . $enclosure; |
466 | 574 | $writeDelimiter = true; |
467 | 575 | } |
@@ -98,22 +98,22 @@ discard block |
||
98 | 98 | * @param array _options options for specific backends |
99 | 99 | * @return bool |
100 | 100 | */ |
101 | - public function __construct( $_stream, array $_options ) { |
|
101 | + public function __construct($_stream, array $_options) { |
|
102 | 102 | if (!is_object($GLOBALS['egw']->translation)) { |
103 | 103 | $GLOBALS['egw']->translation = new Api\Translation(); |
104 | 104 | } |
105 | 105 | $this->translation = &$GLOBALS['egw']->translation; |
106 | 106 | $this->handle = $_stream; |
107 | - if($_options['charset'] == 'user') $_options['charset'] = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset']; |
|
107 | + if ($_options['charset'] == 'user') $_options['charset'] = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset']; |
|
108 | 108 | $this->csv_charset = $_options['charset'] ? $_options['charset'] : 'utf-8'; |
109 | - if ( !empty( $_options ) ) { |
|
110 | - $this->csv_options = array_merge( $this->csv_options, $_options ); |
|
109 | + if (!empty($_options)) { |
|
110 | + $this->csv_options = array_merge($this->csv_options, $_options); |
|
111 | 111 | } |
112 | 112 | //error_log(__METHOD__.__LINE__.array2string($_options['appname'])); |
113 | - if(!Api\Storage\Merge::is_export_limit_excepted()) { |
|
113 | + if (!Api\Storage\Merge::is_export_limit_excepted()) { |
|
114 | 114 | $this->export_limit = Api\Storage\Merge::getExportLimit($_options['appname']); |
115 | 115 | //error_log(__METHOD__.__LINE__.' app:'.$_options['appname'].' limit:'.$this->export_limit); |
116 | - if($this->export_limit == 'no') throw new Api\Exception\NoPermission\Admin('Export disabled'); |
|
116 | + if ($this->export_limit == 'no') throw new Api\Exception\NoPermission\Admin('Export disabled'); |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
@@ -122,15 +122,15 @@ discard block |
||
122 | 122 | * |
123 | 123 | * @param array $_mapping egw_field_name => csv_field_name |
124 | 124 | */ |
125 | - public function set_mapping( array &$_mapping) { |
|
125 | + public function set_mapping(array &$_mapping) { |
|
126 | 126 | if ($this->num_of_records > 0) { |
127 | 127 | throw new Exception('Error: Field mapping can\'t be set during ongoing export!'); |
128 | 128 | } |
129 | - if($_mapping['all_custom_fields']) { |
|
129 | + if ($_mapping['all_custom_fields']) { |
|
130 | 130 | // Field value is the appname, so we can pull the fields |
131 | 131 | $custom = Api\Storage\Customfields::get($_mapping['all_custom_fields']); |
132 | 132 | unset($_mapping['all_custom_fields']); |
133 | - foreach($custom as $field => $info) { |
|
133 | + foreach ($custom as $field => $info) { |
|
134 | 134 | $_mapping['#'.$field] = $this->csv_options['begin_with_fieldnames'] == 'label' ? $info['label'] : $field; |
135 | 135 | } |
136 | 136 | } |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * |
144 | 144 | * @param array $_conversion |
145 | 145 | */ |
146 | - public function set_conversion( array $_conversion) { |
|
146 | + public function set_conversion(array $_conversion) { |
|
147 | 147 | $this->conversion = $_conversion; |
148 | 148 | } |
149 | 149 | |
@@ -153,59 +153,59 @@ discard block |
||
153 | 153 | * @param importexport_iface_egw_record record |
154 | 154 | * @return bool |
155 | 155 | */ |
156 | - public function export_record( importexport_iface_egw_record $_record ) { |
|
156 | + public function export_record(importexport_iface_egw_record $_record) { |
|
157 | 157 | $this->record = $_record; |
158 | 158 | $this->record_array = $_record->get_record_array(); |
159 | 159 | |
160 | 160 | // begin with fieldnames ? |
161 | - if ($this->num_of_records == 0 && $this->csv_options['begin_with_fieldnames'] ) { |
|
162 | - if($this->csv_options['begin_with_fieldnames'] == 'label') { |
|
161 | + if ($this->num_of_records == 0 && $this->csv_options['begin_with_fieldnames']) { |
|
162 | + if ($this->csv_options['begin_with_fieldnames'] == 'label') { |
|
163 | 163 | // Load translations for app |
164 | 164 | list($appname, $part2) = explode('_', get_class($_record)); |
165 | - if(!$GLOBALS['egw_info']['apps'][$appname]) $appname .= $part2; // Handle apps with _ in the name |
|
165 | + if (!$GLOBALS['egw_info']['apps'][$appname]) $appname .= $part2; // Handle apps with _ in the name |
|
166 | 166 | |
167 | 167 | // Get translations from wizard, if possible |
168 | - if(!$this->csv_options['no_header_translation']) |
|
168 | + if (!$this->csv_options['no_header_translation']) |
|
169 | 169 | { |
170 | 170 | $backtrace = debug_backtrace(); |
171 | 171 | $plugin = $backtrace[1]['class']; |
172 | - $wizard_name = $appname . '_wizard_' . str_replace($appname . '_', '', $plugin); |
|
172 | + $wizard_name = $appname.'_wizard_'.str_replace($appname.'_', '', $plugin); |
|
173 | 173 | try { |
174 | 174 | $wizard = new $wizard_name; |
175 | 175 | $fields = $wizard->get_export_fields(); |
176 | - foreach($this->mapping as $field => &$label) |
|
176 | + foreach ($this->mapping as $field => &$label) |
|
177 | 177 | { |
178 | - if($fields[$field]) |
|
178 | + if ($fields[$field]) |
|
179 | 179 | { |
180 | 180 | $label = $label != $fields[$field] ? $fields[$field] : lang($label); |
181 | 181 | } |
182 | 182 | // Make sure no * |
183 | - if(substr($label,-1) == '*') $label = substr($label,0,-1); |
|
183 | + if (substr($label, -1) == '*') $label = substr($label, 0, -1); |
|
184 | 184 | } |
185 | 185 | } catch (Exception $e) { |
186 | 186 | Api\Translation::add_app($appname); |
187 | - foreach($this->mapping as $field => &$label) { |
|
187 | + foreach ($this->mapping as $field => &$label) { |
|
188 | 188 | $label = lang($label); |
189 | 189 | } |
190 | 190 | } |
191 | 191 | } |
192 | 192 | } |
193 | - $mapping = ! empty( $this->mapping ) ? $this->mapping : array_keys ( $this->record_array ); |
|
194 | - self::fputcsv( $this->handle ,$mapping ,$this->csv_options['delimiter'], $this->csv_options['enclosure'] ); |
|
193 | + $mapping = !empty($this->mapping) ? $this->mapping : array_keys($this->record_array); |
|
194 | + self::fputcsv($this->handle, $mapping, $this->csv_options['delimiter'], $this->csv_options['enclosure']); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | // Check for limit |
198 | - if($this->export_limit && $this->num_of_records >= $this->export_limit) { |
|
198 | + if ($this->export_limit && $this->num_of_records >= $this->export_limit) { |
|
199 | 199 | return; |
200 | 200 | } |
201 | 201 | |
202 | 202 | // do conversions |
203 | - if ( !empty( $this->conversion )) { |
|
204 | - $this->record_array = importexport_helper_functions::conversion( $this->record_array, $this->conversion ); |
|
203 | + if (!empty($this->conversion)) { |
|
204 | + $this->record_array = importexport_helper_functions::conversion($this->record_array, $this->conversion); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | // do fieldmapping |
208 | - if ( !empty( $this->mapping ) ) { |
|
208 | + if (!empty($this->mapping)) { |
|
209 | 209 | $record_data = $this->record_array; |
210 | 210 | $this->record_array = array(); |
211 | 211 | foreach ($this->mapping as $egw_field => $csv_field) { |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | } |
214 | 214 | } |
215 | 215 | |
216 | - self::fputcsv( $this->handle, $this->record_array, $this->csv_options['delimiter'], $this->csv_options['enclosure'] ); |
|
216 | + self::fputcsv($this->handle, $this->record_array, $this->csv_options['delimiter'], $this->csv_options['enclosure']); |
|
217 | 217 | $this->num_of_records++; |
218 | 218 | } |
219 | 219 | |
@@ -237,13 +237,13 @@ discard block |
||
237 | 237 | * @return Array of fields to be added to list of fields needing conversion |
238 | 238 | */ |
239 | 239 | public static function convert_parse_custom_fields($appname, &$selects = array(), &$links = array(), &$methods = array()) { |
240 | - if(!$appname) return; |
|
240 | + if (!$appname) return; |
|
241 | 241 | |
242 | 242 | $fields = array(); |
243 | 243 | $custom = Api\Storage\Customfields::get($appname); |
244 | - foreach($custom as $name => $c_field) { |
|
245 | - $name = '#' . $name; |
|
246 | - switch($c_field['type']) { |
|
244 | + foreach ($custom as $name => $c_field) { |
|
245 | + $name = '#'.$name; |
|
246 | + switch ($c_field['type']) { |
|
247 | 247 | case 'date': |
248 | 248 | $fields['date'][] = $name; |
249 | 249 | break; |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | $fields['select-account'][] = $name; |
255 | 255 | break; |
256 | 256 | case 'ajax_select': |
257 | - if($c_field['values']['get_title']) { |
|
257 | + if ($c_field['values']['get_title']) { |
|
258 | 258 | $methods[$name] = $c_field['values']['get_title']; |
259 | 259 | break; |
260 | 260 | } |
@@ -268,8 +268,8 @@ discard block |
||
268 | 268 | $selects[$name] = $c_field['values']; |
269 | 269 | break; |
270 | 270 | default: |
271 | - list($type) = explode('-',$c_field['type'],2); |
|
272 | - if(in_array($type, array_keys($GLOBALS['egw_info']['apps']))) { |
|
271 | + list($type) = explode('-', $c_field['type'], 2); |
|
272 | + if (in_array($type, array_keys($GLOBALS['egw_info']['apps']))) { |
|
273 | 273 | $fields['links'][] = $name; |
274 | 274 | $links[$name] = $c_field['type']; |
275 | 275 | } |
@@ -289,17 +289,17 @@ discard block |
||
289 | 289 | * @param appname Current appname if you want to do custom fields too |
290 | 290 | */ |
291 | 291 | public static function convert(importexport_iface_egw_record &$record, Array $fields = array(), $appname = null, $selects = array()) { |
292 | - if($appname) { |
|
293 | - if(!self::$cf_parse_cache[$appname]) { |
|
292 | + if ($appname) { |
|
293 | + if (!self::$cf_parse_cache[$appname]) { |
|
294 | 294 | $c_fields = self::convert_parse_custom_fields($appname, $selects, $links, $methods); |
295 | 295 | self::$cf_parse_cache[$appname] = array($c_fields, $selects, $links, $methods); |
296 | 296 | } |
297 | 297 | list($c_fields, $c_selects, $links, $methods) = self::$cf_parse_cache[$appname]; |
298 | 298 | |
299 | 299 | // Add in any fields that are keys to another app |
300 | - foreach((array)$fields['links'] as $link_field => $app) |
|
300 | + foreach ((array)$fields['links'] as $link_field => $app) |
|
301 | 301 | { |
302 | - if(is_numeric($link_field)) continue; |
|
302 | + if (is_numeric($link_field)) continue; |
|
303 | 303 | $links[$link_field] = $app; |
304 | 304 | // Set it as a normal link field |
305 | 305 | $fields['links'][] = $link_field; |
@@ -307,8 +307,8 @@ discard block |
||
307 | 307 | } |
308 | 308 | |
309 | 309 | // Not quite a recursive merge, since only one level |
310 | - foreach($fields as $type => &$list) { |
|
311 | - if($c_fields[$type]) { |
|
310 | + foreach ($fields as $type => &$list) { |
|
311 | + if ($c_fields[$type]) { |
|
312 | 312 | $list = array_merge($c_fields[$type], $list); |
313 | 313 | unset($c_fields[$type]); |
314 | 314 | } |
@@ -316,12 +316,12 @@ discard block |
||
316 | 316 | $fields += $c_fields; |
317 | 317 | $selects += $c_selects; |
318 | 318 | } |
319 | - foreach((array)$fields['select'] as $name) { |
|
320 | - if($record->$name != null && is_array($selects) && $selects[$name]) { |
|
319 | + foreach ((array)$fields['select'] as $name) { |
|
320 | + if ($record->$name != null && is_array($selects) && $selects[$name]) { |
|
321 | 321 | $record->$name = is_string($record->$name) ? explode(',', $record->$name) : $record->$name; |
322 | - if(is_array($record->$name)) { |
|
322 | + if (is_array($record->$name)) { |
|
323 | 323 | $names = array(); |
324 | - foreach($record->$name as $_name) { |
|
324 | + foreach ($record->$name as $_name) { |
|
325 | 325 | $names[] = lang($selects[$name][$_name]); |
326 | 326 | } |
327 | 327 | $record->$name = implode(', ', $names); |
@@ -334,18 +334,18 @@ discard block |
||
334 | 334 | $record->$name = ''; |
335 | 335 | } |
336 | 336 | } |
337 | - foreach((array)$fields['links'] as $name) { |
|
338 | - if($record->$name) { |
|
339 | - if(is_numeric($record->$name) && !$links[$name]) { |
|
337 | + foreach ((array)$fields['links'] as $name) { |
|
338 | + if ($record->$name) { |
|
339 | + if (is_numeric($record->$name) && !$links[$name]) { |
|
340 | 340 | $link = Link::get_link($record->$name); |
341 | 341 | $links[$name] = ($link['link_app1'] == $appname ? $link['link_app2'] : $link['link_app1']); |
342 | 342 | $record->$name = ($link['link_app1'] == $appname ? $link['link_id2'] : $link['link_id1']); |
343 | 343 | } |
344 | - if($links[$name]) |
|
344 | + if ($links[$name]) |
|
345 | 345 | { |
346 | 346 | $record->$name = Link::title($links[$name], $record->$name); |
347 | 347 | } |
348 | - else if ( is_array($record->$name) && $record->$name['app'] && $record->$name['id']) |
|
348 | + else if (is_array($record->$name) && $record->$name['app'] && $record->$name['id']) |
|
349 | 349 | { |
350 | 350 | $record->$name = Link::title($record->$name['app'], $record->$name['id']); |
351 | 351 | } |
@@ -355,12 +355,12 @@ discard block |
||
355 | 355 | $record->$name = ''; |
356 | 356 | } |
357 | 357 | } |
358 | - foreach((array)$fields['select-account'] as $name) { |
|
358 | + foreach ((array)$fields['select-account'] as $name) { |
|
359 | 359 | // Compare against null to deal with empty arrays |
360 | 360 | if ($record->$name !== null) { |
361 | - if(is_array($record->$name)) { |
|
361 | + if (is_array($record->$name)) { |
|
362 | 362 | $names = array(); |
363 | - foreach($record->$name as $_name) { |
|
363 | + foreach ($record->$name as $_name) { |
|
364 | 364 | $names[] = Api\Accounts::username($_name); |
365 | 365 | } |
366 | 366 | $record->$name = implode(', ', $names); |
@@ -373,64 +373,64 @@ discard block |
||
373 | 373 | $record->$name = ''; |
374 | 374 | } |
375 | 375 | } |
376 | - foreach((array)$fields['select-bool'] as $name) { |
|
377 | - if($record->$name !== null) { |
|
376 | + foreach ((array)$fields['select-bool'] as $name) { |
|
377 | + if ($record->$name !== null) { |
|
378 | 378 | $record->$name = $record->$name ? lang('Yes') : lang('No'); |
379 | 379 | } |
380 | 380 | } |
381 | - foreach((array)$fields['date-time'] as $name) { |
|
381 | + foreach ((array)$fields['date-time'] as $name) { |
|
382 | 382 | //if ($record->$name) $record->$name = date('Y-m-d H:i:s',$record->$name); // Standard date format |
383 | 383 | if ($record->$name && !is_numeric($record->$name)) $record->$name = strtotime($record->$name); // Custom fields stored as string |
384 | - if ($record->$name && is_numeric($record->$name)) $record->$name = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'] . ' '. |
|
385 | - ($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == '24' ? 'H:i:s' : 'h:i:s a'),$record->$name); // User date format |
|
384 | + if ($record->$name && is_numeric($record->$name)) $record->$name = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'].' '. |
|
385 | + ($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == '24' ? 'H:i:s' : 'h:i:s a'), $record->$name); // User date format |
|
386 | 386 | if (!$record->$name) $record->$name = ''; |
387 | 387 | } |
388 | - foreach((array)$fields['date'] as $name) { |
|
388 | + foreach ((array)$fields['date'] as $name) { |
|
389 | 389 | //if ($record->$name) $record->$name = date('Y-m-d',$record->$name); // Standard date format |
390 | 390 | if ($record->$name && !is_numeric($record->$name)) $record->$name = strtotime($record->$name); // Custom fields stored as string |
391 | 391 | if ($record->$name && is_numeric($record->$name)) $record->$name = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], $record->$name); // User date format |
392 | 392 | if (!$record->$name) $record->$name = ''; |
393 | 393 | } |
394 | - foreach((array)$fields['float'] as $name) |
|
394 | + foreach ((array)$fields['float'] as $name) |
|
395 | 395 | { |
396 | - static $dec_separator,$thousands_separator; |
|
396 | + static $dec_separator, $thousands_separator; |
|
397 | 397 | if (is_null($dec_separator)) |
398 | 398 | { |
399 | 399 | $dec_separator = $GLOBALS['egw_info']['user']['preferences']['common']['number_format'][0]; |
400 | 400 | if (empty($dec_separator)) $dec_separator = '.'; |
401 | 401 | $thousands_separator = $GLOBALS['egw_info']['user']['preferences']['common']['number_format'][1]; |
402 | 402 | } |
403 | - if($record->$name && (string)$record->$name != '') |
|
403 | + if ($record->$name && (string)$record->$name != '') |
|
404 | 404 | { |
405 | - if(!is_numeric($record->$name)) |
|
405 | + if (!is_numeric($record->$name)) |
|
406 | 406 | { |
407 | 407 | $record->$name = floatval(str_replace($dec_separator, '.', preg_replace('/[^\d'.preg_quote($dec_separator).']/', '', $record->$name))); |
408 | 408 | } |
409 | - $record->$name = number_format(str_replace(' ','',$record->$name), 2, |
|
410 | - $dec_separator,$thousands_separator |
|
409 | + $record->$name = number_format(str_replace(' ', '', $record->$name), 2, |
|
410 | + $dec_separator, $thousands_separator |
|
411 | 411 | ); |
412 | 412 | } |
413 | 413 | } |
414 | 414 | |
415 | 415 | // Some custom methods for conversion |
416 | - foreach((array)$methods as $name => $method) { |
|
417 | - if($record->$name) $record->$name = ExecMethod($method, $record->$name); |
|
416 | + foreach ((array)$methods as $name => $method) { |
|
417 | + if ($record->$name) $record->$name = ExecMethod($method, $record->$name); |
|
418 | 418 | } |
419 | 419 | |
420 | 420 | static $cat_object; |
421 | - if(is_null($cat_object)) $cat_object = new Api\Categories(false,$appname); |
|
422 | - foreach((array)$fields['select-cat'] as $name) { |
|
423 | - if($record->$name) { |
|
421 | + if (is_null($cat_object)) $cat_object = new Api\Categories(false, $appname); |
|
422 | + foreach ((array)$fields['select-cat'] as $name) { |
|
423 | + if ($record->$name) { |
|
424 | 424 | $cats = array(); |
425 | 425 | $ids = is_array($record->$name) ? $record->$name : explode(',', $record->$name); |
426 | - foreach($ids as $n => $cat_id) { |
|
426 | + foreach ($ids as $n => $cat_id) { |
|
427 | 427 | |
428 | - if ($cat_id && $cat_object->check_perms(Acl::READ,$cat_id)) |
|
428 | + if ($cat_id && $cat_object->check_perms(Acl::READ, $cat_id)) |
|
429 | 429 | { |
430 | 430 | $cats[] = $cat_object->id2name($cat_id); |
431 | 431 | } |
432 | 432 | } |
433 | - $record->$name = implode(', ',$cats); |
|
433 | + $record->$name = implode(', ', $cats); |
|
434 | 434 | } |
435 | 435 | else |
436 | 436 | { |
@@ -457,18 +457,18 @@ discard block |
||
457 | 457 | * @param char $delimiter |
458 | 458 | * @param char $enclosure |
459 | 459 | */ |
460 | - protected function fputcsv($filePointer, Array $dataArray, $delimiter, $enclosure){ |
|
460 | + protected function fputcsv($filePointer, Array $dataArray, $delimiter, $enclosure) { |
|
461 | 461 | $string = ""; |
462 | 462 | $writeDelimiter = false; |
463 | - foreach($dataArray as $dataElement) { |
|
464 | - if($writeDelimiter) $string .= $delimiter; |
|
465 | - $string .= $enclosure . str_replace(array("\r\n", '"'), array("\n",'""'), $dataElement) . $enclosure; |
|
463 | + foreach ($dataArray as $dataElement) { |
|
464 | + if ($writeDelimiter) $string .= $delimiter; |
|
465 | + $string .= $enclosure.str_replace(array("\r\n", '"'), array("\n", '""'), $dataElement).$enclosure; |
|
466 | 466 | $writeDelimiter = true; |
467 | 467 | } |
468 | 468 | $string .= "\n"; |
469 | 469 | |
470 | 470 | // do charset translation |
471 | - $string = $this->translation->convert( $string, $this->translation->charset(), $this->csv_charset ); |
|
471 | + $string = $this->translation->convert($string, $this->translation->charset(), $this->csv_charset); |
|
472 | 472 | |
473 | 473 | fwrite($filePointer, $string); |
474 | 474 |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | /** |
124 | 124 | * converts accound_lid to account_id |
125 | 125 | * |
126 | - * @param mixed $_account_lid comma seperated list or array with lids |
|
126 | + * @param mixed $_account_lids comma seperated list or array with lids |
|
127 | 127 | * @return mixed comma seperated list or array with ids |
128 | 128 | */ |
129 | 129 | public static function account_name2id( &$_account_lids ) { |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | /** |
204 | 204 | * converts account_ids to account_lids |
205 | 205 | * |
206 | - * @param mixed $_account_ids comma seperated list or array with ids |
|
206 | + * @param mixed $_account_id comma seperated list or array with ids |
|
207 | 207 | * @return mixed comma seperated list or array with lids |
208 | 208 | */ |
209 | 209 | public static function account_id2name( $_account_id ) { |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | /** |
420 | 420 | * returns a list of importexport plugins |
421 | 421 | * |
422 | - * @param string $_tpye {import | export | all} |
|
422 | + * @param string $_type {import | export | all} |
|
423 | 423 | * @param string $_appname {<appname> | all} |
424 | 424 | * @return array(<appname> => array( <type> => array(<plugin> => <title>))) |
425 | 425 | */ |
@@ -591,6 +591,7 @@ discard block |
||
591 | 591 | * |
592 | 592 | * @param $app_name String name of app |
593 | 593 | * @param $plugin_name Name of the plugin |
594 | + * @param importexport_wizard_basic_export_csv $wizard_plugin |
|
594 | 595 | * |
595 | 596 | * @return Array ([fieldname] => array(widget settings), ...) |
596 | 597 | */ |
@@ -32,25 +32,25 @@ discard block |
||
32 | 32 | * Relative date ranges for filtering |
33 | 33 | */ |
34 | 34 | public static $relative_dates = array( // Start: year,month,day,week, End: year,month,day,week |
35 | - 'Today' => array(0,0,0,0, 0,0,1,0), |
|
36 | - 'Yesterday' => array(0,0,-1,0, 0,0,0,0), |
|
37 | - 'This week' => array(0,0,0,0, 0,0,0,1), |
|
38 | - 'Last week' => array(0,0,0,-1, 0,0,0,0), |
|
39 | - 'This month' => array(0,0,0,0, 0,1,0,0), |
|
40 | - 'Last month' => array(0,-1,0,0, 0,0,0,0), |
|
41 | - 'Last 3 months' => array(0,-3,0,0, 0,0,0,0), |
|
42 | - 'This quarter'=> array(0,0,0,0, 0,0,0,0), // Just a marker, needs special handling |
|
43 | - 'Last quarter'=> array(0,-4,0,0, 0,-4,0,0), // Just a marker |
|
44 | - 'This year' => array(0,0,0,0, 1,0,0,0), |
|
45 | - 'Last year' => array(-1,0,0,0, 0,0,0,0), |
|
46 | - '2 years ago' => array(-2,0,0,0, -1,0,0,0), |
|
47 | - '3 years ago' => array(-3,0,0,0, -2,0,0,0), |
|
48 | - ); |
|
35 | + 'Today' => array(0,0,0,0, 0,0,1,0), |
|
36 | + 'Yesterday' => array(0,0,-1,0, 0,0,0,0), |
|
37 | + 'This week' => array(0,0,0,0, 0,0,0,1), |
|
38 | + 'Last week' => array(0,0,0,-1, 0,0,0,0), |
|
39 | + 'This month' => array(0,0,0,0, 0,1,0,0), |
|
40 | + 'Last month' => array(0,-1,0,0, 0,0,0,0), |
|
41 | + 'Last 3 months' => array(0,-3,0,0, 0,0,0,0), |
|
42 | + 'This quarter'=> array(0,0,0,0, 0,0,0,0), // Just a marker, needs special handling |
|
43 | + 'Last quarter'=> array(0,-4,0,0, 0,-4,0,0), // Just a marker |
|
44 | + 'This year' => array(0,0,0,0, 1,0,0,0), |
|
45 | + 'Last year' => array(-1,0,0,0, 0,0,0,0), |
|
46 | + '2 years ago' => array(-2,0,0,0, -1,0,0,0), |
|
47 | + '3 years ago' => array(-3,0,0,0, -2,0,0,0), |
|
48 | + ); |
|
49 | 49 | |
50 | 50 | /** |
51 | - * Files known to cause problems, and will be skipped in a plugin scan |
|
52 | - * If you put appname => true, the whole app will be skipped. |
|
53 | - */ |
|
51 | + * Files known to cause problems, and will be skipped in a plugin scan |
|
52 | + * If you put appname => true, the whole app will be skipped. |
|
53 | + */ |
|
54 | 54 | protected static $blacklist_files = array( |
55 | 55 | 'api' => true, |
56 | 56 | 'etemplate' => true, |
@@ -64,10 +64,10 @@ discard block |
||
64 | 64 | ); |
65 | 65 | |
66 | 66 | /** |
67 | - * Class used to provide extra conversion functions |
|
68 | - * |
|
69 | - * Passed in as a param to conversion() |
|
70 | - */ |
|
67 | + * Class used to provide extra conversion functions |
|
68 | + * |
|
69 | + * Passed in as a param to conversion() |
|
70 | + */ |
|
71 | 71 | protected static $cclass = null; |
72 | 72 | |
73 | 73 | /** |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | return $plugins; |
446 | 446 | } |
447 | 447 | |
448 | - public static function _get_plugins(Array $appnames, Array $types) { |
|
448 | + public static function _get_plugins(array $appnames, array $types) { |
|
449 | 449 | $plugins = array(); |
450 | 450 | foreach ($appnames as $appname) { |
451 | 451 | if(array_key_exists($appname, self::$blacklist_files) && self::$blacklist_files[$appname] === true) continue; |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | } |
563 | 563 | |
564 | 564 | // Api\Cache needs this public |
565 | - public static function _has_definitions(Array $appnames, Array $types) { |
|
565 | + public static function _has_definitions(array $appnames, array $types) { |
|
566 | 566 | $def = new importexport_definitions_bo(array('application'=>$appnames, 'type' => $types)); |
567 | 567 | $list = array(); |
568 | 568 | foreach((array)$def->get_definitions() as $id) { |
@@ -32,19 +32,19 @@ discard block |
||
32 | 32 | * Relative date ranges for filtering |
33 | 33 | */ |
34 | 34 | public static $relative_dates = array( // Start: year,month,day,week, End: year,month,day,week |
35 | - 'Today' => array(0,0,0,0, 0,0,1,0), |
|
36 | - 'Yesterday' => array(0,0,-1,0, 0,0,0,0), |
|
37 | - 'This week' => array(0,0,0,0, 0,0,0,1), |
|
38 | - 'Last week' => array(0,0,0,-1, 0,0,0,0), |
|
39 | - 'This month' => array(0,0,0,0, 0,1,0,0), |
|
40 | - 'Last month' => array(0,-1,0,0, 0,0,0,0), |
|
41 | - 'Last 3 months' => array(0,-3,0,0, 0,0,0,0), |
|
42 | - 'This quarter'=> array(0,0,0,0, 0,0,0,0), // Just a marker, needs special handling |
|
43 | - 'Last quarter'=> array(0,-4,0,0, 0,-4,0,0), // Just a marker |
|
44 | - 'This year' => array(0,0,0,0, 1,0,0,0), |
|
45 | - 'Last year' => array(-1,0,0,0, 0,0,0,0), |
|
46 | - '2 years ago' => array(-2,0,0,0, -1,0,0,0), |
|
47 | - '3 years ago' => array(-3,0,0,0, -2,0,0,0), |
|
35 | + 'Today' => array(0, 0, 0, 0, 0, 0, 1, 0), |
|
36 | + 'Yesterday' => array(0, 0, -1, 0, 0, 0, 0, 0), |
|
37 | + 'This week' => array(0, 0, 0, 0, 0, 0, 0, 1), |
|
38 | + 'Last week' => array(0, 0, 0, -1, 0, 0, 0, 0), |
|
39 | + 'This month' => array(0, 0, 0, 0, 0, 1, 0, 0), |
|
40 | + 'Last month' => array(0, -1, 0, 0, 0, 0, 0, 0), |
|
41 | + 'Last 3 months' => array(0, -3, 0, 0, 0, 0, 0, 0), |
|
42 | + 'This quarter'=> array(0, 0, 0, 0, 0, 0, 0, 0), // Just a marker, needs special handling |
|
43 | + 'Last quarter'=> array(0, -4, 0, 0, 0, -4, 0, 0), // Just a marker |
|
44 | + 'This year' => array(0, 0, 0, 0, 1, 0, 0, 0), |
|
45 | + 'Last year' => array(-1, 0, 0, 0, 0, 0, 0, 0), |
|
46 | + '2 years ago' => array(-2, 0, 0, 0, -1, 0, 0, 0), |
|
47 | + '3 years ago' => array(-3, 0, 0, 0, -2, 0, 0, 0), |
|
48 | 48 | ); |
49 | 49 | |
50 | 50 | /** |
@@ -85,22 +85,22 @@ discard block |
||
85 | 85 | * @param string $_format format of time string e.g.: d.m.Y H:i |
86 | 86 | * @param int $_is_dst is day light saving time? 0 = no, 1 = yes, -1 = system default |
87 | 87 | */ |
88 | - public static function custom_strtotime( $_string, $_format='', $_is_dst = -1) { |
|
89 | - if ( empty( $_format ) ) return strtotime( $_string ); |
|
90 | - $fparams = explode( ',', chunk_split( $_format, 1, ',' ) ); |
|
88 | + public static function custom_strtotime($_string, $_format = '', $_is_dst = -1) { |
|
89 | + if (empty($_format)) return strtotime($_string); |
|
90 | + $fparams = explode(',', chunk_split($_format, 1, ',')); |
|
91 | 91 | $spos = 0; |
92 | - foreach ( $fparams as $fparam ) { |
|
93 | - |
|
94 | - switch ( $fparam ) { |
|
95 | - case 'd': (int)$day = substr( $_string, $spos, 2 ); $spos += 2; break; |
|
96 | - case 'm': (int)$mon = substr( $_string, $spos, 2 ); $spos += 2; break; |
|
97 | - case 'y': (int)$year = substr( $_string, $spos, 2 ); $spos += 2; break; |
|
98 | - case 'Y': (int)$year = substr( $_string, $spos, 4 ); $spos += 4; break; |
|
99 | - case 'H': (int)$hour = substr( $_string, $spos, 2 ); $spos += 2; break; |
|
100 | - case 'h': (int)$hour = substr( $_string, $spos, 2 ); $spos += 2; break; |
|
101 | - case 'i': (int)$min = substr( $_string, $spos, 2 ); $spos += 2; break; |
|
102 | - case 's': (int)$sec = substr( $_string, $spos, 2 ); $spos += 2; break; |
|
103 | - case 'O': (int)$offset = $year = substr( $_string, $spos, 5 ); $spos += 5; break; |
|
92 | + foreach ($fparams as $fparam) { |
|
93 | + |
|
94 | + switch ($fparam) { |
|
95 | + case 'd': (int)$day = substr($_string, $spos, 2); $spos += 2; break; |
|
96 | + case 'm': (int)$mon = substr($_string, $spos, 2); $spos += 2; break; |
|
97 | + case 'y': (int)$year = substr($_string, $spos, 2); $spos += 2; break; |
|
98 | + case 'Y': (int)$year = substr($_string, $spos, 4); $spos += 4; break; |
|
99 | + case 'H': (int)$hour = substr($_string, $spos, 2); $spos += 2; break; |
|
100 | + case 'h': (int)$hour = substr($_string, $spos, 2); $spos += 2; break; |
|
101 | + case 'i': (int)$min = substr($_string, $spos, 2); $spos += 2; break; |
|
102 | + case 's': (int)$sec = substr($_string, $spos, 2); $spos += 2; break; |
|
103 | + case 'O': (int)$offset = $year = substr($_string, $spos, 5); $spos += 5; break; |
|
104 | 104 | case 'a': (int)$hour = $fparam == 'am' ? $hour : $hour + 12; break; |
105 | 105 | case 'A': (int)$hour = $fparam == 'AM' ? $hour : $hour + 12; break; |
106 | 106 | default: $spos++; // seperator |
@@ -111,11 +111,11 @@ discard block |
||
111 | 111 | $timestamp = mktime($hour, $min, $sec, $mon, $day, $year, $_is_dst); |
112 | 112 | |
113 | 113 | // offset given? |
114 | - if ( isset( $offset ) && strlen( $offset == 5 ) ) { |
|
114 | + if (isset($offset) && strlen($offset == 5)) { |
|
115 | 115 | $operator = $offset{0}; |
116 | - $ohour = 60 * 60 * (int)substr( $offset, 1, 2 ); |
|
117 | - $omin = 60 * (int)substr( $offset, 3, 2 ); |
|
118 | - if ( $operator == '+' ) $timestamp += $ohour + $omin; |
|
116 | + $ohour = 60 * 60 * (int)substr($offset, 1, 2); |
|
117 | + $omin = 60 * (int)substr($offset, 3, 2); |
|
118 | + if ($operator == '+') $timestamp += $ohour + $omin; |
|
119 | 119 | else $timestamp -= $ohour + $omin; |
120 | 120 | } |
121 | 121 | return $timestamp; |
@@ -126,11 +126,11 @@ discard block |
||
126 | 126 | * @param mixed $_account_lid comma seperated list or array with lids |
127 | 127 | * @return mixed comma seperated list or array with ids |
128 | 128 | */ |
129 | - public static function account_name2id( &$_account_lids ) { |
|
130 | - $account_lids = is_array( $_account_lids ) ? $_account_lids : explode( ',', $_account_lids ); |
|
129 | + public static function account_name2id(&$_account_lids) { |
|
130 | + $account_lids = is_array($_account_lids) ? $_account_lids : explode(',', $_account_lids); |
|
131 | 131 | $skip = false; |
132 | - foreach ( $account_lids as $key => $account_lid ) { |
|
133 | - if($skip) { |
|
132 | + foreach ($account_lids as $key => $account_lid) { |
|
133 | + if ($skip) { |
|
134 | 134 | unset($account_lids[$key]); |
135 | 135 | $skip = false; |
136 | 136 | continue; |
@@ -138,15 +138,15 @@ discard block |
||
138 | 138 | $account_lid = trim($account_lid); |
139 | 139 | |
140 | 140 | // Handle any IDs that slip in |
141 | - if(is_numeric($account_lid) && $GLOBALS['egw']->accounts->id2name($account_lid)) { |
|
141 | + if (is_numeric($account_lid) && $GLOBALS['egw']->accounts->id2name($account_lid)) { |
|
142 | 142 | unset($account_lids[$key]); |
143 | 143 | $account_ids[] = (int)$account_lid; |
144 | 144 | continue; |
145 | 145 | } |
146 | 146 | // Check for [username] |
147 | - if(strpos($account_lid,'[') !== false) |
|
147 | + if (strpos($account_lid, '[') !== false) |
|
148 | 148 | { |
149 | - if(preg_match('/\[(.+)\]/',$account_lid,$matches)) |
|
149 | + if (preg_match('/\[(.+)\]/', $account_lid, $matches)) |
|
150 | 150 | { |
151 | 151 | $account_id = $GLOBALS['egw']->accounts->name2id($matches[1]); |
152 | 152 | unset($account_lids[$key]); |
@@ -157,59 +157,59 @@ discard block |
||
157 | 157 | |
158 | 158 | // Handle users listed as Lastname, Firstname instead of login ID |
159 | 159 | // Do this first, in case their first name matches a username |
160 | - if ( $account_lids[$key+1][0] == ' ') |
|
160 | + if ($account_lids[$key + 1][0] == ' ') |
|
161 | 161 | { |
162 | 162 | $query = array('type' => 'accounts', 'query_type' => 'exact'); |
163 | - $given = $GLOBALS['egw']->accounts->search($query + array('query' => trim($account_lids[$key+1]))); |
|
163 | + $given = $GLOBALS['egw']->accounts->search($query + array('query' => trim($account_lids[$key + 1]))); |
|
164 | 164 | $family = $GLOBALS['egw']->accounts->search($query + array('query' => trim($account_lid))); |
165 | 165 | $ids = array_intersect_key($family, $given); |
166 | - if($ids) |
|
166 | + if ($ids) |
|
167 | 167 | { |
168 | 168 | $account_ids[] = key($ids); |
169 | 169 | unset($account_lids[$key]); |
170 | 170 | $skip = true; // Skip the next one, it's the first name |
171 | - continue ; |
|
171 | + continue; |
|
172 | 172 | } |
173 | 173 | } |
174 | 174 | |
175 | 175 | // Deal with groups listed as <name> Group, remove the Group |
176 | - if(substr(trim($account_lid),-strlen(lang('Group'))) == lang('Group')) |
|
176 | + if (substr(trim($account_lid), -strlen(lang('Group'))) == lang('Group')) |
|
177 | 177 | { |
178 | 178 | $account_lid = trim(substr(trim($account_lid), 0, -strlen(lang('Group')))); |
179 | 179 | } |
180 | 180 | // Group <name> (no comma) |
181 | - else if(strpos($account_lid, lang('Group')) === 0) |
|
181 | + else if (strpos($account_lid, lang('Group')) === 0) |
|
182 | 182 | { |
183 | 183 | $account_lid = trim(substr(trim($account_lid), strlen(lang('Group')))); |
184 | 184 | } |
185 | 185 | |
186 | - if ( $account_id = $GLOBALS['egw']->accounts->name2id( $account_lid )) { |
|
186 | + if ($account_id = $GLOBALS['egw']->accounts->name2id($account_lid)) { |
|
187 | 187 | $account_ids[] = $account_id; |
188 | 188 | unset($account_lids[$key]); |
189 | 189 | continue; |
190 | 190 | } |
191 | - if ( $account_id = $GLOBALS['egw']->accounts->name2id( trim($account_lid), 'account_fullname' )) { |
|
191 | + if ($account_id = $GLOBALS['egw']->accounts->name2id(trim($account_lid), 'account_fullname')) { |
|
192 | 192 | $account_ids[] = $account_id; |
193 | 193 | unset($account_lids[$key]); |
194 | 194 | continue; |
195 | 195 | } |
196 | 196 | |
197 | 197 | // Handle groups listed as Group, <name> |
198 | - if ( $account_lids[$key][0] == ' ' && $account_id = $GLOBALS['egw']->accounts->name2id( $account_lid)) { |
|
198 | + if ($account_lids[$key][0] == ' ' && $account_id = $GLOBALS['egw']->accounts->name2id($account_lid)) { |
|
199 | 199 | $account_ids[] = $account_id; |
200 | - unset($account_lids[$key-1]); |
|
200 | + unset($account_lids[$key - 1]); |
|
201 | 201 | unset($account_lids[$key]); |
202 | 202 | continue; |
203 | 203 | } |
204 | 204 | // Group, <name> - remove the Group part |
205 | - if($account_lid == lang('Group')) |
|
205 | + if ($account_lid == lang('Group')) |
|
206 | 206 | { |
207 | 207 | unset($account_lids[$key]); |
208 | 208 | continue; |
209 | 209 | } |
210 | 210 | } |
211 | - $_account_lids = (is_array($_account_lids) ? $account_lids : implode(',',array_unique($account_lids))); |
|
212 | - return is_array( $_account_lids ) ? array_unique($account_ids) : implode( ',', array_unique((array)$account_ids )); |
|
211 | + $_account_lids = (is_array($_account_lids) ? $account_lids : implode(',', array_unique($account_lids))); |
|
212 | + return is_array($_account_lids) ? array_unique($account_ids) : implode(',', array_unique((array)$account_ids)); |
|
213 | 213 | |
214 | 214 | } // end of member function account_lid2id |
215 | 215 | |
@@ -219,14 +219,14 @@ discard block |
||
219 | 219 | * @param mixed $_account_ids comma seperated list or array with ids |
220 | 220 | * @return mixed comma seperated list or array with lids |
221 | 221 | */ |
222 | - public static function account_id2name( $_account_id ) { |
|
223 | - $account_ids = is_array( $_account_id ) ? $_account_id : explode( ',', $_account_id ); |
|
224 | - foreach ( $account_ids as $account_id ) { |
|
225 | - if ( $account_lid = $GLOBALS['egw']->accounts->id2name( $account_id )) { |
|
222 | + public static function account_id2name($_account_id) { |
|
223 | + $account_ids = is_array($_account_id) ? $_account_id : explode(',', $_account_id); |
|
224 | + foreach ($account_ids as $account_id) { |
|
225 | + if ($account_lid = $GLOBALS['egw']->accounts->id2name($account_id)) { |
|
226 | 226 | $account_lids[] = $account_lid; |
227 | 227 | } |
228 | 228 | } |
229 | - return is_array( $_account_id ) ? $account_lids : implode( ',', (array)$account_lids ); |
|
229 | + return is_array($_account_id) ? $account_lids : implode(',', (array)$account_lids); |
|
230 | 230 | } // end of member function account_id2lid |
231 | 231 | |
232 | 232 | /** |
@@ -235,12 +235,12 @@ discard block |
||
235 | 235 | * @param mixed _cat_ids comma seperated list or array |
236 | 236 | * @return mixed comma seperated list or array with cat_names |
237 | 237 | */ |
238 | - public static function cat_id2name( $_cat_ids ) { |
|
239 | - $cat_ids = is_array( $_cat_ids ) ? $_cat_ids : explode( ',', $_cat_ids ); |
|
240 | - foreach ( $cat_ids as $cat_id ) { |
|
241 | - $cat_names[] = Api\Categories::id2name( (int)$cat_id ); |
|
238 | + public static function cat_id2name($_cat_ids) { |
|
239 | + $cat_ids = is_array($_cat_ids) ? $_cat_ids : explode(',', $_cat_ids); |
|
240 | + foreach ($cat_ids as $cat_id) { |
|
241 | + $cat_names[] = Api\Categories::id2name((int)$cat_id); |
|
242 | 242 | } |
243 | - return is_array( $_cat_ids ) ? $cat_names : implode(',',(array)$cat_names); |
|
243 | + return is_array($_cat_ids) ? $cat_names : implode(',', (array)$cat_names); |
|
244 | 244 | } // end of member function category_id2name |
245 | 245 | |
246 | 246 | /** |
@@ -251,24 +251,24 @@ discard block |
||
251 | 251 | * @param int $parent Optional parent ID to use for new categories |
252 | 252 | * @return mixed comma seperated list or array with cat_ids |
253 | 253 | */ |
254 | - public static function cat_name2id( $_cat_names, $parent = 0 ) { |
|
255 | - $cats = new Api\Categories(); // uses current user and app (egw_info[flags][currentapp]) |
|
254 | + public static function cat_name2id($_cat_names, $parent = 0) { |
|
255 | + $cats = new Api\Categories(); // uses current user and app (egw_info[flags][currentapp]) |
|
256 | 256 | |
257 | - $cat_names = is_array( $_cat_names ) ? $_cat_names : explode( ',', $_cat_names ); |
|
258 | - foreach ( $cat_names as $cat_name ) { |
|
257 | + $cat_names = is_array($_cat_names) ? $_cat_names : explode(',', $_cat_names); |
|
258 | + foreach ($cat_names as $cat_name) { |
|
259 | 259 | $cat_name = trim($cat_name); |
260 | - if ( $cat_name == '' ) continue; |
|
261 | - if ( ( $cat_id = $cats->name2id( $cat_name ) ) == 0 && !self::$dry_run) { |
|
262 | - $cat_id = $cats->add( array( |
|
260 | + if ($cat_name == '') continue; |
|
261 | + if (($cat_id = $cats->name2id($cat_name)) == 0 && !self::$dry_run) { |
|
262 | + $cat_id = $cats->add(array( |
|
263 | 263 | 'name' => $cat_name, |
264 | 264 | 'parent' => $parent, |
265 | 265 | 'access' => 'public', |
266 | - 'descr' => $cat_name. ' ('. lang('Automatically created by importexport'). ')' |
|
266 | + 'descr' => $cat_name.' ('.lang('Automatically created by importexport').')' |
|
267 | 267 | )); |
268 | 268 | } |
269 | 269 | $cat_ids[] = $cat_id; |
270 | 270 | } |
271 | - return is_array( $_cat_names ) ? $cat_ids : implode( ',', (array)$cat_ids ); |
|
271 | + return is_array($_cat_names) ? $cat_ids : implode(',', (array)$cat_ids); |
|
272 | 272 | |
273 | 273 | } // end of member function category_name2id |
274 | 274 | |
@@ -307,76 +307,76 @@ discard block |
||
307 | 307 | * @param object &$cclass calling class to process the '@ evals' |
308 | 308 | * @return bool |
309 | 309 | */ |
310 | - public static function conversion( &$_record, $_conversion, &$_cclass = null ) { |
|
311 | - if (empty( $_conversion ) ) return $_record; |
|
310 | + public static function conversion(&$_record, $_conversion, &$_cclass = null) { |
|
311 | + if (empty($_conversion)) return $_record; |
|
312 | 312 | |
313 | - self::$cclass =& $_cclass; |
|
313 | + self::$cclass = & $_cclass; |
|
314 | 314 | |
315 | 315 | $PSep = '||'; // Pattern-Separator, separats the pattern-replacement-pairs in conversion |
316 | 316 | $ASep = '|>'; // Assignment-Separator, separats pattern and replacesment |
317 | - $CPre = '|['; $CPos = ']'; // |[_record-idx] is expanded to the corespondig value |
|
317 | + $CPre = '|['; $CPos = ']'; // |[_record-idx] is expanded to the corespondig value |
|
318 | 318 | $TPre = '|T{'; $TPos = '}'; // |{_record-idx} is trimmed |
319 | - $CntlPre = '|TC{'; // Filter all cntl-chars \x01-\x1f and trim |
|
320 | - $CntlnCLPre = '|TCnCL{'; // Like |C{ but allowes CR and LF |
|
321 | - $INE = '|INE{'; // Only insert if stuff in ^^ is not empty |
|
319 | + $CntlPre = '|TC{'; // Filter all cntl-chars \x01-\x1f and trim |
|
320 | + $CntlnCLPre = '|TCnCL{'; // Like |C{ but allowes CR and LF |
|
321 | + $INE = '|INE{'; // Only insert if stuff in ^^ is not empty |
|
322 | 322 | |
323 | - foreach ( $_conversion as $idx => $conversion_string ) { |
|
324 | - if ( empty( $conversion_string ) ) continue; |
|
323 | + foreach ($_conversion as $idx => $conversion_string) { |
|
324 | + if (empty($conversion_string)) continue; |
|
325 | 325 | |
326 | 326 | // fetch patterns ($rvalues) |
327 | 327 | $rvalues = array(); |
328 | - $pat_reps = explode( $PSep, stripslashes( $conversion_string ) ); |
|
329 | - foreach( $pat_reps as $k => $pat_rep ) { |
|
330 | - list( $pattern, $replace ) = explode( $ASep, $pat_rep, 2 ); |
|
331 | - if( $replace == '' ) { |
|
328 | + $pat_reps = explode($PSep, stripslashes($conversion_string)); |
|
329 | + foreach ($pat_reps as $k => $pat_rep) { |
|
330 | + list($pattern, $replace) = explode($ASep, $pat_rep, 2); |
|
331 | + if ($replace == '') { |
|
332 | 332 | $replace = $pattern; $pattern = '^.*$'; |
333 | 333 | } |
334 | - $rvalues[$pattern] = $replace; // replace two with only one, added by the form |
|
334 | + $rvalues[$pattern] = $replace; // replace two with only one, added by the form |
|
335 | 335 | } |
336 | 336 | |
337 | 337 | // conversion list may be longer than $_record aka (no_csv) |
338 | - $val = array_key_exists( $idx, $_record ) ? $_record[$idx] : ''; |
|
338 | + $val = array_key_exists($idx, $_record) ? $_record[$idx] : ''; |
|
339 | 339 | |
340 | 340 | $c_functions = array('cat', 'account', 'strtotime', 'list'); |
341 | - if($_cclass) { |
|
341 | + if ($_cclass) { |
|
342 | 342 | // Add in additional methods |
343 | 343 | $reflection = new ReflectionClass(get_class($_cclass)); |
344 | 344 | $methods = $reflection->getMethods(ReflectionMethod::IS_STATIC); |
345 | - foreach($methods as $method) { |
|
345 | + foreach ($methods as $method) { |
|
346 | 346 | $c_functions[] = $method->name; |
347 | 347 | } |
348 | 348 | } |
349 | 349 | $c_functions = implode('|', $c_functions); |
350 | - foreach ( $rvalues as $pattern => $replace ) { |
|
350 | + foreach ($rvalues as $pattern => $replace) { |
|
351 | 351 | // Allow to include record indexes in pattern |
352 | 352 | $reg = '/\|\[([0-9]+)\]/'; |
353 | - while( preg_match( $reg, $pattern, $vars ) ) { |
|
353 | + while (preg_match($reg, $pattern, $vars)) { |
|
354 | 354 | // expand all _record fields |
355 | 355 | $pattern = str_replace( |
356 | - $CPre . $vars[1] . $CPos, |
|
356 | + $CPre.$vars[1].$CPos, |
|
357 | 357 | $_record[array_search($vars[1], array_keys($_record))], |
358 | 358 | $pattern |
359 | 359 | ); |
360 | 360 | } |
361 | - if( preg_match('/'. (string)$pattern.'/', $val) ) { |
|
361 | + if (preg_match('/'.(string)$pattern.'/', $val)) { |
|
362 | 362 | |
363 | - $val = preg_replace( '/'.(string)$pattern.'/', $replace, (string)$val ); |
|
363 | + $val = preg_replace('/'.(string)$pattern.'/', $replace, (string)$val); |
|
364 | 364 | |
365 | 365 | $reg = '/\|\[([a-zA-Z_0-9]+)\]/'; |
366 | - while( preg_match( $reg, $val, $vars ) ) { |
|
366 | + while (preg_match($reg, $val, $vars)) { |
|
367 | 367 | // expand all _record fields |
368 | 368 | $val = str_replace( |
369 | - $CPre . $vars[1] . $CPos, |
|
369 | + $CPre.$vars[1].$CPos, |
|
370 | 370 | $_record[array_search($vars[1], array_keys($_record))], |
371 | 371 | $val |
372 | 372 | ); |
373 | 373 | } |
374 | - $val = preg_replace_callback( "/($c_functions)\(([^)]*)\)/i", array( self, 'c2_dispatcher') , $val ); |
|
374 | + $val = preg_replace_callback("/($c_functions)\(([^)]*)\)/i", array(self, 'c2_dispatcher'), $val); |
|
375 | 375 | break; |
376 | 376 | } |
377 | 377 | } |
378 | 378 | // clean each field |
379 | - $val = preg_replace_callback("/(\|T\{|\|TC\{|\|TCnCL\{|\|INE\{)(.*)\}/", array( self, 'strclean'), $val ); |
|
379 | + $val = preg_replace_callback("/(\|T\{|\|TC\{|\|TCnCL\{|\|INE\{)(.*)\}/", array(self, 'strclean'), $val); |
|
380 | 380 | |
381 | 381 | $_record[$idx] = $val; |
382 | 382 | } |
@@ -390,42 +390,42 @@ discard block |
||
390 | 390 | * |
391 | 391 | * @param array $_matches |
392 | 392 | */ |
393 | - private static function c2_dispatcher( $_matches ) { |
|
393 | + private static function c2_dispatcher($_matches) { |
|
394 | 394 | $action = &$_matches[1]; // cat or account ... |
395 | - $data = &$_matches[2]; // datas for action |
|
395 | + $data = &$_matches[2]; // datas for action |
|
396 | 396 | |
397 | - switch ( $action ) { |
|
397 | + switch ($action) { |
|
398 | 398 | case 'strtotime' : |
399 | - list( $string, $format ) = explode( ',', $data ); |
|
400 | - return self::custom_strtotime( trim( $string ), trim( $format ) ); |
|
399 | + list($string, $format) = explode(',', $data); |
|
400 | + return self::custom_strtotime(trim($string), trim($format)); |
|
401 | 401 | case 'list': |
402 | - list( $split, $data, $index) = explode(',',$data); |
|
402 | + list($split, $data, $index) = explode(',', $data); |
|
403 | 403 | $exploded = explode($split, $data); |
404 | 404 | // 1 based indexing for user ease |
405 | 405 | return $exploded[$index - 1]; |
406 | 406 | default : |
407 | - if(self::$cclass && method_exists(self::$cclass, $action)) { |
|
407 | + if (self::$cclass && method_exists(self::$cclass, $action)) { |
|
408 | 408 | $class = get_class(self::$cclass); |
409 | 409 | return call_user_func("$class::$action", $data); |
410 | 410 | } |
411 | - $method = (string)$action. ( is_int( $data ) ? '_id2name' : '_name2id' ); |
|
412 | - if(self::$cclass && method_exists(self::$cclass, $method)) { |
|
411 | + $method = (string)$action.(is_int($data) ? '_id2name' : '_name2id'); |
|
412 | + if (self::$cclass && method_exists(self::$cclass, $method)) { |
|
413 | 413 | $class = get_class(self::$cclass); |
414 | 414 | return call_user_func("$class::$action", $data); |
415 | 415 | } else { |
416 | - return self::$method( $data ); |
|
416 | + return self::$method($data); |
|
417 | 417 | } |
418 | 418 | } |
419 | 419 | } |
420 | 420 | |
421 | - private static function strclean( $_matches ) { |
|
422 | - switch( $_matches[1] ) { |
|
423 | - case '|T{' : return trim( $_matches[2] ); |
|
424 | - case '|TC{' : return trim( preg_replace( '/[\x01-\x1F]+/', '', $_matches[2] ) ); |
|
425 | - case '|TCnCL{' : return trim( preg_replace( '/[\x01-\x09\x11\x12\x14-\x1F]+/', '', $_matches[2] ) ); |
|
426 | - case '|INE{' : return preg_match( '/\^.+\^/', $_matches[2] ) ? $_matches[2] : ''; |
|
421 | + private static function strclean($_matches) { |
|
422 | + switch ($_matches[1]) { |
|
423 | + case '|T{' : return trim($_matches[2]); |
|
424 | + case '|TC{' : return trim(preg_replace('/[\x01-\x1F]+/', '', $_matches[2])); |
|
425 | + case '|TCnCL{' : return trim(preg_replace('/[\x01-\x09\x11\x12\x14-\x1F]+/', '', $_matches[2])); |
|
426 | + case '|INE{' : return preg_match('/\^.+\^/', $_matches[2]) ? $_matches[2] : ''; |
|
427 | 427 | default: |
428 | - throw new Exception('Error in conversion string! "'. substr( $_matches[1], 0, -1 ). '" is not valid!'); |
|
428 | + throw new Exception('Error in conversion string! "'.substr($_matches[1], 0, -1).'" is not valid!'); |
|
429 | 429 | } |
430 | 430 | } |
431 | 431 | |
@@ -436,23 +436,23 @@ discard block |
||
436 | 436 | * @param string $_appname {<appname> | all} |
437 | 437 | * @return array(<appname> => array( <type> => array(<plugin> => <title>))) |
438 | 438 | */ |
439 | - public static function get_plugins( $_appname = 'all', $_type = 'all' ) { |
|
439 | + public static function get_plugins($_appname = 'all', $_type = 'all') { |
|
440 | 440 | $plugins = Api\Cache::getTree( |
441 | 441 | __CLASS__, |
442 | 442 | 'plugins', |
443 | - array('importexport_helper_functions','_get_plugins'), |
|
443 | + array('importexport_helper_functions', '_get_plugins'), |
|
444 | 444 | array(array_keys($GLOBALS['egw_info']['apps']), array('import', 'export')), |
445 | 445 | self::CACHE_EXPIRATION |
446 | 446 | ); |
447 | 447 | $appnames = $_appname == 'all' ? array_keys($GLOBALS['egw_info']['apps']) : (array)$_appname; |
448 | - $types = $_type == 'all' ? array('import','export') : (array)$_type; |
|
448 | + $types = $_type == 'all' ? array('import', 'export') : (array)$_type; |
|
449 | 449 | |
450 | 450 | // Testing: comment out Api\Cache call, use this |
451 | 451 | //$plugins = self::_get_plugins($appnames, $types); |
452 | - foreach($plugins as $appname => $_types) { |
|
453 | - if(!in_array($appname, $appnames)) unset($plugins[$appname]); |
|
452 | + foreach ($plugins as $appname => $_types) { |
|
453 | + if (!in_array($appname, $appnames)) unset($plugins[$appname]); |
|
454 | 454 | } |
455 | - foreach($plugins as $appname => $types) { |
|
455 | + foreach ($plugins as $appname => $types) { |
|
456 | 456 | $plugins[$appname] = array_intersect_key($plugins[$appname], $types); |
457 | 457 | } |
458 | 458 | return $plugins; |
@@ -461,25 +461,25 @@ discard block |
||
461 | 461 | public static function _get_plugins(Array $appnames, Array $types) { |
462 | 462 | $plugins = array(); |
463 | 463 | foreach ($appnames as $appname) { |
464 | - if(array_key_exists($appname, self::$blacklist_files) && self::$blacklist_files[$appname] === true) continue; |
|
464 | + if (array_key_exists($appname, self::$blacklist_files) && self::$blacklist_files[$appname] === true) continue; |
|
465 | 465 | |
466 | - $appdir = EGW_INCLUDE_ROOT. "/$appname/inc"; |
|
467 | - if(!is_dir($appdir)) continue; |
|
466 | + $appdir = EGW_INCLUDE_ROOT."/$appname/inc"; |
|
467 | + if (!is_dir($appdir)) continue; |
|
468 | 468 | $d = dir($appdir); |
469 | 469 | |
470 | 470 | // step through each file in appdir |
471 | 471 | while (false !== ($entry = $d->read())) { |
472 | 472 | // Blacklisted? |
473 | - if(is_array(self::$blacklist_files[$appname]) && in_array($entry, self::$blacklist_files[$appname])) continue; |
|
473 | + if (is_array(self::$blacklist_files[$appname]) && in_array($entry, self::$blacklist_files[$appname])) continue; |
|
474 | 474 | if (!preg_match('/^class\.([^.]+)\.inc\.php$/', $entry, $matches)) continue; |
475 | 475 | $classname = $matches[1]; |
476 | - $file = $appdir. '/'. $entry; |
|
476 | + $file = $appdir.'/'.$entry; |
|
477 | 477 | |
478 | 478 | foreach ($types as $type) { |
479 | - if( !is_file($file) || strpos($entry, $type) === false || strpos($entry,'wizard') !== false) continue; |
|
479 | + if (!is_file($file) || strpos($entry, $type) === false || strpos($entry, 'wizard') !== false) continue; |
|
480 | 480 | require_once($file); |
481 | 481 | $reflectionClass = new ReflectionClass($classname); |
482 | - if($reflectionClass->IsInstantiable() && |
|
482 | + if ($reflectionClass->IsInstantiable() && |
|
483 | 483 | $reflectionClass->implementsInterface('importexport_iface_'.$type.'_plugin')) { |
484 | 484 | try { |
485 | 485 | $plugin_object = new $classname; |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | $d->close(); |
496 | 496 | |
497 | 497 | $config = Api\Config::read('importexport'); |
498 | - if($config['update'] == 'auto') { |
|
498 | + if ($config['update'] == 'auto') { |
|
499 | 499 | self::load_defaults($appname); |
500 | 500 | } |
501 | 501 | } |
@@ -510,37 +510,37 @@ discard block |
||
510 | 510 | * @return array $num => $appname |
511 | 511 | */ |
512 | 512 | public static function get_apps($_type, $ignore_acl = false) { |
513 | - $apps = array_keys(self::get_plugins('all',$_type)); |
|
514 | - if($ignore_acl) return $apps; |
|
513 | + $apps = array_keys(self::get_plugins('all', $_type)); |
|
514 | + if ($ignore_acl) return $apps; |
|
515 | 515 | |
516 | - foreach($apps as $key => $app) { |
|
517 | - if(!self::has_definitions($app, $_type)) unset($apps[$key]); |
|
516 | + foreach ($apps as $key => $app) { |
|
517 | + if (!self::has_definitions($app, $_type)) unset($apps[$key]); |
|
518 | 518 | } |
519 | 519 | return $apps; |
520 | 520 | } |
521 | 521 | |
522 | 522 | public static function load_defaults($appname) { |
523 | 523 | // Check for new definitions to import from $appname/setup/*.xml |
524 | - $appdir = EGW_INCLUDE_ROOT. "/$appname/setup"; |
|
525 | - if(!is_dir($appdir)) return; |
|
524 | + $appdir = EGW_INCLUDE_ROOT."/$appname/setup"; |
|
525 | + if (!is_dir($appdir)) return; |
|
526 | 526 | $d = dir($appdir); |
527 | 527 | |
528 | 528 | // step through each file in app's setup |
529 | 529 | while (false !== ($entry = $d->read())) { |
530 | - $file = $appdir. '/'. $entry; |
|
531 | - list( $filename, $extension) = explode('.',$entry); |
|
532 | - if ( $extension != 'xml' ) continue; |
|
530 | + $file = $appdir.'/'.$entry; |
|
531 | + list($filename, $extension) = explode('.', $entry); |
|
532 | + if ($extension != 'xml') continue; |
|
533 | 533 | try { |
534 | 534 | // import will skip invalid files |
535 | - importexport_definitions_bo::import( $file ); |
|
535 | + importexport_definitions_bo::import($file); |
|
536 | 536 | } catch (Exception $e) { |
537 | - error_log(__CLASS__.__FUNCTION__. " import $appname definitions: " . $e->getMessage()); |
|
537 | + error_log(__CLASS__.__FUNCTION__." import $appname definitions: ".$e->getMessage()); |
|
538 | 538 | } |
539 | 539 | } |
540 | 540 | $d->close(); |
541 | 541 | } |
542 | 542 | |
543 | - public static function guess_filetype( $_file ) { |
|
543 | + public static function guess_filetype($_file) { |
|
544 | 544 | |
545 | 545 | } |
546 | 546 | |
@@ -551,24 +551,24 @@ discard block |
||
551 | 551 | * @param string $_type {import | export | all} |
552 | 552 | * @return boolean |
553 | 553 | */ |
554 | - public static function has_definitions( $_appname = 'all', $_type = 'all' ) { |
|
554 | + public static function has_definitions($_appname = 'all', $_type = 'all') { |
|
555 | 555 | $definitions = Api\Cache::getSession( |
556 | 556 | __CLASS__, |
557 | 557 | 'has_definitions', |
558 | - array('importexport_helper_functions','_has_definitions'), |
|
558 | + array('importexport_helper_functions', '_has_definitions'), |
|
559 | 559 | array(array_keys($GLOBALS['egw_info']['apps']), array('import', 'export')), |
560 | 560 | self::CACHE_EXPIRATION |
561 | 561 | ); |
562 | 562 | $appnames = $_appname == 'all' ? array_keys($GLOBALS['egw_info']['apps']) : (array)$_appname; |
563 | - $types = $_type == 'all' ? array('import','export') : (array)$_type; |
|
563 | + $types = $_type == 'all' ? array('import', 'export') : (array)$_type; |
|
564 | 564 | |
565 | 565 | // Testing: Comment out cache call above, use this |
566 | 566 | //$definitions = self::_has_definitions($appnames, $types); |
567 | 567 | |
568 | - foreach($definitions as $appname => $_types) { |
|
569 | - if(!in_array($appname, $appnames)) unset($definitions[$appname]); |
|
568 | + foreach ($definitions as $appname => $_types) { |
|
569 | + if (!in_array($appname, $appnames)) unset($definitions[$appname]); |
|
570 | 570 | } |
571 | - foreach($definitions as $appname => $_types) { |
|
571 | + foreach ($definitions as $appname => $_types) { |
|
572 | 572 | $definitions[$appname] = array_intersect_key($definitions[$appname], array_flip($types)); |
573 | 573 | } |
574 | 574 | return !empty($definitions[$appname]); |
@@ -578,11 +578,11 @@ discard block |
||
578 | 578 | public static function _has_definitions(Array $appnames, Array $types) { |
579 | 579 | $def = new importexport_definitions_bo(array('application'=>$appnames, 'type' => $types)); |
580 | 580 | $list = array(); |
581 | - foreach((array)$def->get_definitions() as $id) { |
|
581 | + foreach ((array)$def->get_definitions() as $id) { |
|
582 | 582 | // Need to instanciate it to check, but if the user doesn't have permission, it throws an exception |
583 | 583 | try { |
584 | 584 | $definition = new importexport_definition($id); |
585 | - if($def->is_permitted($definition->get_record_array())) { |
|
585 | + if ($def->is_permitted($definition->get_record_array())) { |
|
586 | 586 | $list[$definition->application][$definition->type][] = $id; |
587 | 587 | } |
588 | 588 | } catch (Exception $e) { |
@@ -614,13 +614,13 @@ discard block |
||
614 | 614 | $plugin = is_object($plugin_name) ? $plugin_name : new $plugin_name(); |
615 | 615 | $plugin_name = get_class($plugin); |
616 | 616 | |
617 | - if($record_classname == null) $record_classname = $plugin::get_egw_record_class(); |
|
618 | - if(!class_exists($record_classname)) throw new Exception('Bad class name ' . $record_classname); |
|
617 | + if ($record_classname == null) $record_classname = $plugin::get_egw_record_class(); |
|
618 | + if (!class_exists($record_classname)) throw new Exception('Bad class name '.$record_classname); |
|
619 | 619 | |
620 | - if(!$wizard_plugin) |
|
620 | + if (!$wizard_plugin) |
|
621 | 621 | { |
622 | - $wizard_name = $app_name . '_wizard_' . str_replace($app_name . '_', '', $plugin_name); |
|
623 | - if(!class_exists($wizard_name)) throw new Exception('Bad wizard name ' . $wizard_name); |
|
622 | + $wizard_name = $app_name.'_wizard_'.str_replace($app_name.'_', '', $plugin_name); |
|
623 | + if (!class_exists($wizard_name)) throw new Exception('Bad wizard name '.$wizard_name); |
|
624 | 624 | $wizard_plugin = new $wizard_name; |
625 | 625 | } |
626 | 626 | } |
@@ -632,16 +632,16 @@ discard block |
||
632 | 632 | |
633 | 633 | // Get field -> label map and initialize fields using wizard field order |
634 | 634 | $fields = $export_fields = array(); |
635 | - if(method_exists($wizard_plugin, 'get_export_fields')) |
|
635 | + if (method_exists($wizard_plugin, 'get_export_fields')) |
|
636 | 636 | { |
637 | 637 | $fields = $export_fields = $wizard_plugin->get_export_fields(); |
638 | 638 | } |
639 | 639 | |
640 | - foreach($record_classname::$types as $type => $type_fields) |
|
640 | + foreach ($record_classname::$types as $type => $type_fields) |
|
641 | 641 | { |
642 | 642 | // Only these for now, until filter methods for others are figured out |
643 | - if(!in_array($type, array('select','select-cat','select-account','date','date-time'))) continue; |
|
644 | - foreach($type_fields as $field_name) |
|
643 | + if (!in_array($type, array('select', 'select-cat', 'select-account', 'date', 'date-time'))) continue; |
|
644 | + foreach ($type_fields as $field_name) |
|
645 | 645 | { |
646 | 646 | $fields[$field_name] = array( |
647 | 647 | 'name' => $field_name, |
@@ -652,21 +652,21 @@ discard block |
||
652 | 652 | } |
653 | 653 | // Add custom fields |
654 | 654 | $custom = Api\Storage\Customfields::get($app_name); |
655 | - foreach($custom as $field_name => $settings) |
|
655 | + foreach ($custom as $field_name => $settings) |
|
656 | 656 | { |
657 | 657 | $settings['name'] = '#'.$field_name; |
658 | 658 | $fields['#'.$field_name] = $settings; |
659 | 659 | } |
660 | 660 | |
661 | - foreach($fields as $field_name => &$settings) { |
|
661 | + foreach ($fields as $field_name => &$settings) { |
|
662 | 662 | // Can't really filter on these (or at least no generic, sane way figured out yet) |
663 | - if(!is_array($settings) || in_array($settings['type'], array('text','button', 'label','url','url-email','url-phone','htmlarea'))) |
|
663 | + if (!is_array($settings) || in_array($settings['type'], array('text', 'button', 'label', 'url', 'url-email', 'url-phone', 'htmlarea'))) |
|
664 | 664 | { |
665 | 665 | unset($fields[$field_name]); |
666 | 666 | continue; |
667 | 667 | } |
668 | - if($settings['type'] == 'radio') $settings['type'] = 'select'; |
|
669 | - switch($settings['type']) |
|
668 | + if ($settings['type'] == 'radio') $settings['type'] = 'select'; |
|
669 | + switch ($settings['type']) |
|
670 | 670 | { |
671 | 671 | case 'checkbox': |
672 | 672 | // This isn't quite right - there's only 2 options and you can select both |
@@ -689,7 +689,7 @@ discard block |
||
689 | 689 | } |
690 | 690 | } |
691 | 691 | |
692 | - if(method_exists($plugin, 'get_filter_fields')) |
|
692 | + if (method_exists($plugin, 'get_filter_fields')) |
|
693 | 693 | { |
694 | 694 | $plugin->get_filter_fields($fields); |
695 | 695 | } |
@@ -705,65 +705,65 @@ discard block |
||
705 | 705 | */ |
706 | 706 | public static function date_rel2abs($value) |
707 | 707 | { |
708 | - if(is_array($value)) |
|
708 | + if (is_array($value)) |
|
709 | 709 | { |
710 | 710 | $abs = array(); |
711 | - foreach($value as $key => $val) |
|
711 | + foreach ($value as $key => $val) |
|
712 | 712 | { |
713 | 713 | $abs[$key] = self::date_rel2abs($val); |
714 | 714 | } |
715 | 715 | return $abs; |
716 | 716 | } |
717 | - if($date = self::$relative_dates[$value]) |
|
717 | + if ($date = self::$relative_dates[$value]) |
|
718 | 718 | { |
719 | - $year = (int) date('Y'); |
|
720 | - $month = (int) date('m'); |
|
721 | - $day = (int) date('d'); |
|
722 | - $today = mktime(0,0,0,date('m'),date('d'),date('Y')); |
|
719 | + $year = (int)date('Y'); |
|
720 | + $month = (int)date('m'); |
|
721 | + $day = (int)date('d'); |
|
722 | + $today = mktime(0, 0, 0, date('m'), date('d'), date('Y')); |
|
723 | 723 | |
724 | - list($syear,$smonth,$sday,$sweek,$eyear,$emonth,$eday,$eweek) = $date; |
|
724 | + list($syear, $smonth, $sday, $sweek, $eyear, $emonth, $eday, $eweek) = $date; |
|
725 | 725 | |
726 | - if(stripos($value, 'quarter') !== false) |
|
726 | + if (stripos($value, 'quarter') !== false) |
|
727 | 727 | { |
728 | 728 | // Handle quarters |
729 | - $start = mktime(0,0,0,((int)floor(($smonth+$month) / 3.1)) * 3 + 1, 1, $year); |
|
730 | - $end = mktime(0,0,0,((int)floor(($emonth+$month) / 3.1)+1) * 3 + 1, 1, $year); |
|
729 | + $start = mktime(0, 0, 0, ((int)floor(($smonth + $month) / 3.1)) * 3 + 1, 1, $year); |
|
730 | + $end = mktime(0, 0, 0, ((int)floor(($emonth + $month) / 3.1) + 1) * 3 + 1, 1, $year); |
|
731 | 731 | } |
732 | 732 | elseif ($syear || $eyear) |
733 | 733 | { |
734 | - $start = mktime(0,0,0,1,1,$syear+$year); |
|
735 | - $end = mktime(0,0,0,1,1,$eyear+$year); |
|
734 | + $start = mktime(0, 0, 0, 1, 1, $syear + $year); |
|
735 | + $end = mktime(0, 0, 0, 1, 1, $eyear + $year); |
|
736 | 736 | } |
737 | 737 | elseif ($smonth || $emonth) |
738 | 738 | { |
739 | - $start = mktime(0,0,0,$smonth+$month,1,$year); |
|
740 | - $end = mktime(0,0,0,$emonth+$month,1,$year); |
|
739 | + $start = mktime(0, 0, 0, $smonth + $month, 1, $year); |
|
740 | + $end = mktime(0, 0, 0, $emonth + $month, 1, $year); |
|
741 | 741 | } |
742 | 742 | elseif ($sday || $eday) |
743 | 743 | { |
744 | - $start = mktime(0,0,0,$month,$sday+$day,$year); |
|
745 | - $end = mktime(0,0,0,$month,$eday+$day,$year); |
|
744 | + $start = mktime(0, 0, 0, $month, $sday + $day, $year); |
|
745 | + $end = mktime(0, 0, 0, $month, $eday + $day, $year); |
|
746 | 746 | } |
747 | 747 | elseif ($sweek || $eweek) |
748 | 748 | { |
749 | - $wday = (int) date('w'); // 0=sun, ..., 6=sat |
|
750 | - switch($GLOBALS['egw_info']['user']['preferences']['calendar']['weekdaystarts']) |
|
749 | + $wday = (int)date('w'); // 0=sun, ..., 6=sat |
|
750 | + switch ($GLOBALS['egw_info']['user']['preferences']['calendar']['weekdaystarts']) |
|
751 | 751 | { |
752 | 752 | case 'Sunday': |
753 | - $weekstart = $today - $wday * 24*60*60; |
|
753 | + $weekstart = $today - $wday * 24 * 60 * 60; |
|
754 | 754 | break; |
755 | 755 | case 'Saturday': |
756 | - $weekstart = $today - (6-$wday) * 24*60*60; |
|
756 | + $weekstart = $today - (6 - $wday) * 24 * 60 * 60; |
|
757 | 757 | break; |
758 | 758 | case 'Moday': |
759 | 759 | default: |
760 | - $weekstart = $today - ($wday ? $wday-1 : 6) * 24*60*60; |
|
760 | + $weekstart = $today - ($wday ? $wday - 1 : 6) * 24 * 60 * 60; |
|
761 | 761 | break; |
762 | 762 | } |
763 | - $start = $weekstart + $sweek*7*24*60*60; |
|
764 | - $end = $weekstart + $eweek*7*24*60*60; |
|
763 | + $start = $weekstart + $sweek * 7 * 24 * 60 * 60; |
|
764 | + $end = $weekstart + $eweek * 7 * 24 * 60 * 60; |
|
765 | 765 | } |
766 | - $end_param = $end - 24*60*60; |
|
766 | + $end_param = $end - 24 * 60 * 60; |
|
767 | 767 | |
768 | 768 | // Take 1 second off end to provide an inclusive range.for filtering |
769 | 769 | $end -= 1; |
@@ -16,7 +16,8 @@ discard block |
||
16 | 16 | * class importexport_helper_functions (only static methods) |
17 | 17 | * use importexport_helper_functions::method |
18 | 18 | */ |
19 | -class importexport_helper_functions { |
|
19 | +class importexport_helper_functions |
|
20 | +{ |
|
20 | 21 | |
21 | 22 | /** |
22 | 23 | * Plugins are scanned and cached for all instances using this source path for given time (in seconds) |
@@ -85,13 +86,19 @@ discard block |
||
85 | 86 | * @param string $_format format of time string e.g.: d.m.Y H:i |
86 | 87 | * @param int $_is_dst is day light saving time? 0 = no, 1 = yes, -1 = system default |
87 | 88 | */ |
88 | - public static function custom_strtotime( $_string, $_format='', $_is_dst = -1) { |
|
89 | - if ( empty( $_format ) ) return strtotime( $_string ); |
|
89 | + public static function custom_strtotime( $_string, $_format='', $_is_dst = -1) |
|
90 | + { |
|
91 | + if ( empty( $_format ) ) |
|
92 | + { |
|
93 | + return strtotime( $_string ); |
|
94 | + } |
|
90 | 95 | $fparams = explode( ',', chunk_split( $_format, 1, ',' ) ); |
91 | 96 | $spos = 0; |
92 | - foreach ( $fparams as $fparam ) { |
|
97 | + foreach ( $fparams as $fparam ) |
|
98 | + { |
|
93 | 99 | |
94 | - switch ( $fparam ) { |
|
100 | + switch ( $fparam ) |
|
101 | + { |
|
95 | 102 | case 'd': (int)$day = substr( $_string, $spos, 2 ); $spos += 2; break; |
96 | 103 | case 'm': (int)$mon = substr( $_string, $spos, 2 ); $spos += 2; break; |
97 | 104 | case 'y': (int)$year = substr( $_string, $spos, 2 ); $spos += 2; break; |
@@ -111,12 +118,18 @@ discard block |
||
111 | 118 | $timestamp = mktime($hour, $min, $sec, $mon, $day, $year, $_is_dst); |
112 | 119 | |
113 | 120 | // offset given? |
114 | - if ( isset( $offset ) && strlen( $offset == 5 ) ) { |
|
121 | + if ( isset( $offset ) && strlen( $offset == 5 ) ) |
|
122 | + { |
|
115 | 123 | $operator = $offset{0}; |
116 | 124 | $ohour = 60 * 60 * (int)substr( $offset, 1, 2 ); |
117 | 125 | $omin = 60 * (int)substr( $offset, 3, 2 ); |
118 | - if ( $operator == '+' ) $timestamp += $ohour + $omin; |
|
119 | - else $timestamp -= $ohour + $omin; |
|
126 | + if ( $operator == '+' ) |
|
127 | + { |
|
128 | + $timestamp += $ohour + $omin; |
|
129 | + } |
|
130 | + else { |
|
131 | + $timestamp -= $ohour + $omin; |
|
132 | + } |
|
120 | 133 | } |
121 | 134 | return $timestamp; |
122 | 135 | } |
@@ -126,11 +139,14 @@ discard block |
||
126 | 139 | * @param mixed $_account_lid comma seperated list or array with lids |
127 | 140 | * @return mixed comma seperated list or array with ids |
128 | 141 | */ |
129 | - public static function account_name2id( &$_account_lids ) { |
|
142 | + public static function account_name2id( &$_account_lids ) |
|
143 | + { |
|
130 | 144 | $account_lids = is_array( $_account_lids ) ? $_account_lids : explode( ',', $_account_lids ); |
131 | 145 | $skip = false; |
132 | - foreach ( $account_lids as $key => $account_lid ) { |
|
133 | - if($skip) { |
|
146 | + foreach ( $account_lids as $key => $account_lid ) |
|
147 | + { |
|
148 | + if($skip) |
|
149 | + { |
|
134 | 150 | unset($account_lids[$key]); |
135 | 151 | $skip = false; |
136 | 152 | continue; |
@@ -138,7 +154,8 @@ discard block |
||
138 | 154 | $account_lid = trim($account_lid); |
139 | 155 | |
140 | 156 | // Handle any IDs that slip in |
141 | - if(is_numeric($account_lid) && $GLOBALS['egw']->accounts->id2name($account_lid)) { |
|
157 | + if(is_numeric($account_lid) && $GLOBALS['egw']->accounts->id2name($account_lid)) |
|
158 | + { |
|
142 | 159 | unset($account_lids[$key]); |
143 | 160 | $account_ids[] = (int)$account_lid; |
144 | 161 | continue; |
@@ -183,19 +200,22 @@ discard block |
||
183 | 200 | $account_lid = trim(substr(trim($account_lid), strlen(lang('Group')))); |
184 | 201 | } |
185 | 202 | |
186 | - if ( $account_id = $GLOBALS['egw']->accounts->name2id( $account_lid )) { |
|
203 | + if ( $account_id = $GLOBALS['egw']->accounts->name2id( $account_lid )) |
|
204 | + { |
|
187 | 205 | $account_ids[] = $account_id; |
188 | 206 | unset($account_lids[$key]); |
189 | 207 | continue; |
190 | 208 | } |
191 | - if ( $account_id = $GLOBALS['egw']->accounts->name2id( trim($account_lid), 'account_fullname' )) { |
|
209 | + if ( $account_id = $GLOBALS['egw']->accounts->name2id( trim($account_lid), 'account_fullname' )) |
|
210 | + { |
|
192 | 211 | $account_ids[] = $account_id; |
193 | 212 | unset($account_lids[$key]); |
194 | 213 | continue; |
195 | 214 | } |
196 | 215 | |
197 | 216 | // Handle groups listed as Group, <name> |
198 | - if ( $account_lids[$key][0] == ' ' && $account_id = $GLOBALS['egw']->accounts->name2id( $account_lid)) { |
|
217 | + if ( $account_lids[$key][0] == ' ' && $account_id = $GLOBALS['egw']->accounts->name2id( $account_lid)) |
|
218 | + { |
|
199 | 219 | $account_ids[] = $account_id; |
200 | 220 | unset($account_lids[$key-1]); |
201 | 221 | unset($account_lids[$key]); |
@@ -219,10 +239,13 @@ discard block |
||
219 | 239 | * @param mixed $_account_ids comma seperated list or array with ids |
220 | 240 | * @return mixed comma seperated list or array with lids |
221 | 241 | */ |
222 | - public static function account_id2name( $_account_id ) { |
|
242 | + public static function account_id2name( $_account_id ) |
|
243 | + { |
|
223 | 244 | $account_ids = is_array( $_account_id ) ? $_account_id : explode( ',', $_account_id ); |
224 | - foreach ( $account_ids as $account_id ) { |
|
225 | - if ( $account_lid = $GLOBALS['egw']->accounts->id2name( $account_id )) { |
|
245 | + foreach ( $account_ids as $account_id ) |
|
246 | + { |
|
247 | + if ( $account_lid = $GLOBALS['egw']->accounts->id2name( $account_id )) |
|
248 | + { |
|
226 | 249 | $account_lids[] = $account_lid; |
227 | 250 | } |
228 | 251 | } |
@@ -235,9 +258,11 @@ discard block |
||
235 | 258 | * @param mixed _cat_ids comma seperated list or array |
236 | 259 | * @return mixed comma seperated list or array with cat_names |
237 | 260 | */ |
238 | - public static function cat_id2name( $_cat_ids ) { |
|
261 | + public static function cat_id2name( $_cat_ids ) |
|
262 | + { |
|
239 | 263 | $cat_ids = is_array( $_cat_ids ) ? $_cat_ids : explode( ',', $_cat_ids ); |
240 | - foreach ( $cat_ids as $cat_id ) { |
|
264 | + foreach ( $cat_ids as $cat_id ) |
|
265 | + { |
|
241 | 266 | $cat_names[] = Api\Categories::id2name( (int)$cat_id ); |
242 | 267 | } |
243 | 268 | return is_array( $_cat_ids ) ? $cat_names : implode(',',(array)$cat_names); |
@@ -251,14 +276,20 @@ discard block |
||
251 | 276 | * @param int $parent Optional parent ID to use for new categories |
252 | 277 | * @return mixed comma seperated list or array with cat_ids |
253 | 278 | */ |
254 | - public static function cat_name2id( $_cat_names, $parent = 0 ) { |
|
279 | + public static function cat_name2id( $_cat_names, $parent = 0 ) |
|
280 | + { |
|
255 | 281 | $cats = new Api\Categories(); // uses current user and app (egw_info[flags][currentapp]) |
256 | 282 | |
257 | 283 | $cat_names = is_array( $_cat_names ) ? $_cat_names : explode( ',', $_cat_names ); |
258 | - foreach ( $cat_names as $cat_name ) { |
|
284 | + foreach ( $cat_names as $cat_name ) |
|
285 | + { |
|
259 | 286 | $cat_name = trim($cat_name); |
260 | - if ( $cat_name == '' ) continue; |
|
261 | - if ( ( $cat_id = $cats->name2id( $cat_name ) ) == 0 && !self::$dry_run) { |
|
287 | + if ( $cat_name == '' ) |
|
288 | + { |
|
289 | + continue; |
|
290 | + } |
|
291 | + if ( ( $cat_id = $cats->name2id( $cat_name ) ) == 0 && !self::$dry_run) |
|
292 | + { |
|
262 | 293 | $cat_id = $cats->add( array( |
263 | 294 | 'name' => $cat_name, |
264 | 295 | 'parent' => $parent, |
@@ -307,8 +338,12 @@ discard block |
||
307 | 338 | * @param object &$cclass calling class to process the '@ evals' |
308 | 339 | * @return bool |
309 | 340 | */ |
310 | - public static function conversion( &$_record, $_conversion, &$_cclass = null ) { |
|
311 | - if (empty( $_conversion ) ) return $_record; |
|
341 | + public static function conversion( &$_record, $_conversion, &$_cclass = null ) |
|
342 | + { |
|
343 | + if (empty( $_conversion ) ) |
|
344 | + { |
|
345 | + return $_record; |
|
346 | + } |
|
312 | 347 | |
313 | 348 | self::$cclass =& $_cclass; |
314 | 349 | |
@@ -320,15 +355,21 @@ discard block |
||
320 | 355 | $CntlnCLPre = '|TCnCL{'; // Like |C{ but allowes CR and LF |
321 | 356 | $INE = '|INE{'; // Only insert if stuff in ^^ is not empty |
322 | 357 | |
323 | - foreach ( $_conversion as $idx => $conversion_string ) { |
|
324 | - if ( empty( $conversion_string ) ) continue; |
|
358 | + foreach ( $_conversion as $idx => $conversion_string ) |
|
359 | + { |
|
360 | + if ( empty( $conversion_string ) ) |
|
361 | + { |
|
362 | + continue; |
|
363 | + } |
|
325 | 364 | |
326 | 365 | // fetch patterns ($rvalues) |
327 | 366 | $rvalues = array(); |
328 | 367 | $pat_reps = explode( $PSep, stripslashes( $conversion_string ) ); |
329 | - foreach( $pat_reps as $k => $pat_rep ) { |
|
368 | + foreach( $pat_reps as $k => $pat_rep ) |
|
369 | + { |
|
330 | 370 | list( $pattern, $replace ) = explode( $ASep, $pat_rep, 2 ); |
331 | - if( $replace == '' ) { |
|
371 | + if( $replace == '' ) |
|
372 | + { |
|
332 | 373 | $replace = $pattern; $pattern = '^.*$'; |
333 | 374 | } |
334 | 375 | $rvalues[$pattern] = $replace; // replace two with only one, added by the form |
@@ -338,19 +379,23 @@ discard block |
||
338 | 379 | $val = array_key_exists( $idx, $_record ) ? $_record[$idx] : ''; |
339 | 380 | |
340 | 381 | $c_functions = array('cat', 'account', 'strtotime', 'list'); |
341 | - if($_cclass) { |
|
382 | + if($_cclass) |
|
383 | + { |
|
342 | 384 | // Add in additional methods |
343 | 385 | $reflection = new ReflectionClass(get_class($_cclass)); |
344 | 386 | $methods = $reflection->getMethods(ReflectionMethod::IS_STATIC); |
345 | - foreach($methods as $method) { |
|
387 | + foreach($methods as $method) |
|
388 | + { |
|
346 | 389 | $c_functions[] = $method->name; |
347 | 390 | } |
348 | 391 | } |
349 | 392 | $c_functions = implode('|', $c_functions); |
350 | - foreach ( $rvalues as $pattern => $replace ) { |
|
393 | + foreach ( $rvalues as $pattern => $replace ) |
|
394 | + { |
|
351 | 395 | // Allow to include record indexes in pattern |
352 | 396 | $reg = '/\|\[([0-9]+)\]/'; |
353 | - while( preg_match( $reg, $pattern, $vars ) ) { |
|
397 | + while( preg_match( $reg, $pattern, $vars ) ) |
|
398 | + { |
|
354 | 399 | // expand all _record fields |
355 | 400 | $pattern = str_replace( |
356 | 401 | $CPre . $vars[1] . $CPos, |
@@ -358,12 +403,14 @@ discard block |
||
358 | 403 | $pattern |
359 | 404 | ); |
360 | 405 | } |
361 | - if( preg_match('/'. (string)$pattern.'/', $val) ) { |
|
406 | + if( preg_match('/'. (string)$pattern.'/', $val) ) |
|
407 | + { |
|
362 | 408 | |
363 | 409 | $val = preg_replace( '/'.(string)$pattern.'/', $replace, (string)$val ); |
364 | 410 | |
365 | 411 | $reg = '/\|\[([a-zA-Z_0-9]+)\]/'; |
366 | - while( preg_match( $reg, $val, $vars ) ) { |
|
412 | + while( preg_match( $reg, $val, $vars ) ) |
|
413 | + { |
|
367 | 414 | // expand all _record fields |
368 | 415 | $val = str_replace( |
369 | 416 | $CPre . $vars[1] . $CPos, |
@@ -390,11 +437,13 @@ discard block |
||
390 | 437 | * |
391 | 438 | * @param array $_matches |
392 | 439 | */ |
393 | - private static function c2_dispatcher( $_matches ) { |
|
440 | + private static function c2_dispatcher( $_matches ) |
|
441 | + { |
|
394 | 442 | $action = &$_matches[1]; // cat or account ... |
395 | 443 | $data = &$_matches[2]; // datas for action |
396 | 444 | |
397 | - switch ( $action ) { |
|
445 | + switch ( $action ) |
|
446 | + { |
|
398 | 447 | case 'strtotime' : |
399 | 448 | list( $string, $format ) = explode( ',', $data ); |
400 | 449 | return self::custom_strtotime( trim( $string ), trim( $format ) ); |
@@ -404,22 +453,28 @@ discard block |
||
404 | 453 | // 1 based indexing for user ease |
405 | 454 | return $exploded[$index - 1]; |
406 | 455 | default : |
407 | - if(self::$cclass && method_exists(self::$cclass, $action)) { |
|
456 | + if(self::$cclass && method_exists(self::$cclass, $action)) |
|
457 | + { |
|
408 | 458 | $class = get_class(self::$cclass); |
409 | 459 | return call_user_func("$class::$action", $data); |
410 | 460 | } |
411 | 461 | $method = (string)$action. ( is_int( $data ) ? '_id2name' : '_name2id' ); |
412 | - if(self::$cclass && method_exists(self::$cclass, $method)) { |
|
462 | + if(self::$cclass && method_exists(self::$cclass, $method)) |
|
463 | + { |
|
413 | 464 | $class = get_class(self::$cclass); |
414 | 465 | return call_user_func("$class::$action", $data); |
415 | - } else { |
|
466 | + } |
|
467 | + else |
|
468 | + { |
|
416 | 469 | return self::$method( $data ); |
417 | 470 | } |
418 | 471 | } |
419 | 472 | } |
420 | 473 | |
421 | - private static function strclean( $_matches ) { |
|
422 | - switch( $_matches[1] ) { |
|
474 | + private static function strclean( $_matches ) |
|
475 | + { |
|
476 | + switch( $_matches[1] ) |
|
477 | + { |
|
423 | 478 | case '|T{' : return trim( $_matches[2] ); |
424 | 479 | case '|TC{' : return trim( preg_replace( '/[\x01-\x1F]+/', '', $_matches[2] ) ); |
425 | 480 | case '|TCnCL{' : return trim( preg_replace( '/[\x01-\x09\x11\x12\x14-\x1F]+/', '', $_matches[2] ) ); |
@@ -436,7 +491,8 @@ discard block |
||
436 | 491 | * @param string $_appname {<appname> | all} |
437 | 492 | * @return array(<appname> => array( <type> => array(<plugin> => <title>))) |
438 | 493 | */ |
439 | - public static function get_plugins( $_appname = 'all', $_type = 'all' ) { |
|
494 | + public static function get_plugins( $_appname = 'all', $_type = 'all' ) |
|
495 | + { |
|
440 | 496 | $plugins = Api\Cache::getTree( |
441 | 497 | __CLASS__, |
442 | 498 | 'plugins', |
@@ -449,38 +505,63 @@ discard block |
||
449 | 505 | |
450 | 506 | // Testing: comment out Api\Cache call, use this |
451 | 507 | //$plugins = self::_get_plugins($appnames, $types); |
452 | - foreach($plugins as $appname => $_types) { |
|
453 | - if(!in_array($appname, $appnames)) unset($plugins[$appname]); |
|
508 | + foreach($plugins as $appname => $_types) |
|
509 | + { |
|
510 | + if(!in_array($appname, $appnames)) |
|
511 | + { |
|
512 | + unset($plugins[$appname]); |
|
513 | + } |
|
454 | 514 | } |
455 | - foreach($plugins as $appname => $types) { |
|
515 | + foreach($plugins as $appname => $types) |
|
516 | + { |
|
456 | 517 | $plugins[$appname] = array_intersect_key($plugins[$appname], $types); |
457 | 518 | } |
458 | 519 | return $plugins; |
459 | 520 | } |
460 | 521 | |
461 | - public static function _get_plugins(Array $appnames, Array $types) { |
|
522 | + public static function _get_plugins(Array $appnames, Array $types) |
|
523 | + { |
|
462 | 524 | $plugins = array(); |
463 | - foreach ($appnames as $appname) { |
|
464 | - if(array_key_exists($appname, self::$blacklist_files) && self::$blacklist_files[$appname] === true) continue; |
|
525 | + foreach ($appnames as $appname) |
|
526 | + { |
|
527 | + if(array_key_exists($appname, self::$blacklist_files) && self::$blacklist_files[$appname] === true) |
|
528 | + { |
|
529 | + continue; |
|
530 | + } |
|
465 | 531 | |
466 | 532 | $appdir = EGW_INCLUDE_ROOT. "/$appname/inc"; |
467 | - if(!is_dir($appdir)) continue; |
|
533 | + if(!is_dir($appdir)) |
|
534 | + { |
|
535 | + continue; |
|
536 | + } |
|
468 | 537 | $d = dir($appdir); |
469 | 538 | |
470 | 539 | // step through each file in appdir |
471 | - while (false !== ($entry = $d->read())) { |
|
540 | + while (false !== ($entry = $d->read())) |
|
541 | + { |
|
472 | 542 | // Blacklisted? |
473 | - if(is_array(self::$blacklist_files[$appname]) && in_array($entry, self::$blacklist_files[$appname])) continue; |
|
474 | - if (!preg_match('/^class\.([^.]+)\.inc\.php$/', $entry, $matches)) continue; |
|
543 | + if(is_array(self::$blacklist_files[$appname]) && in_array($entry, self::$blacklist_files[$appname])) |
|
544 | + { |
|
545 | + continue; |
|
546 | + } |
|
547 | + if (!preg_match('/^class\.([^.]+)\.inc\.php$/', $entry, $matches)) |
|
548 | + { |
|
549 | + continue; |
|
550 | + } |
|
475 | 551 | $classname = $matches[1]; |
476 | 552 | $file = $appdir. '/'. $entry; |
477 | 553 | |
478 | - foreach ($types as $type) { |
|
479 | - if( !is_file($file) || strpos($entry, $type) === false || strpos($entry,'wizard') !== false) continue; |
|
554 | + foreach ($types as $type) |
|
555 | + { |
|
556 | + if( !is_file($file) || strpos($entry, $type) === false || strpos($entry,'wizard') !== false) |
|
557 | + { |
|
558 | + continue; |
|
559 | + } |
|
480 | 560 | require_once($file); |
481 | 561 | $reflectionClass = new ReflectionClass($classname); |
482 | 562 | if($reflectionClass->IsInstantiable() && |
483 | - $reflectionClass->implementsInterface('importexport_iface_'.$type.'_plugin')) { |
|
563 | + $reflectionClass->implementsInterface('importexport_iface_'.$type.'_plugin')) |
|
564 | + { |
|
484 | 565 | try { |
485 | 566 | $plugin_object = new $classname; |
486 | 567 | } |
@@ -495,7 +576,8 @@ discard block |
||
495 | 576 | $d->close(); |
496 | 577 | |
497 | 578 | $config = Api\Config::read('importexport'); |
498 | - if($config['update'] == 'auto') { |
|
579 | + if($config['update'] == 'auto') |
|
580 | + { |
|
499 | 581 | self::load_defaults($appname); |
500 | 582 | } |
501 | 583 | } |
@@ -509,38 +591,56 @@ discard block |
||
509 | 591 | * @param string $_type |
510 | 592 | * @return array $num => $appname |
511 | 593 | */ |
512 | - public static function get_apps($_type, $ignore_acl = false) { |
|
594 | + public static function get_apps($_type, $ignore_acl = false) |
|
595 | + { |
|
513 | 596 | $apps = array_keys(self::get_plugins('all',$_type)); |
514 | - if($ignore_acl) return $apps; |
|
597 | + if($ignore_acl) |
|
598 | + { |
|
599 | + return $apps; |
|
600 | + } |
|
515 | 601 | |
516 | - foreach($apps as $key => $app) { |
|
517 | - if(!self::has_definitions($app, $_type)) unset($apps[$key]); |
|
602 | + foreach($apps as $key => $app) |
|
603 | + { |
|
604 | + if(!self::has_definitions($app, $_type)) |
|
605 | + { |
|
606 | + unset($apps[$key]); |
|
607 | + } |
|
518 | 608 | } |
519 | 609 | return $apps; |
520 | 610 | } |
521 | 611 | |
522 | - public static function load_defaults($appname) { |
|
612 | + public static function load_defaults($appname) |
|
613 | + { |
|
523 | 614 | // Check for new definitions to import from $appname/setup/*.xml |
524 | 615 | $appdir = EGW_INCLUDE_ROOT. "/$appname/setup"; |
525 | - if(!is_dir($appdir)) return; |
|
616 | + if(!is_dir($appdir)) |
|
617 | + { |
|
618 | + return; |
|
619 | + } |
|
526 | 620 | $d = dir($appdir); |
527 | 621 | |
528 | 622 | // step through each file in app's setup |
529 | - while (false !== ($entry = $d->read())) { |
|
623 | + while (false !== ($entry = $d->read())) |
|
624 | + { |
|
530 | 625 | $file = $appdir. '/'. $entry; |
531 | 626 | list( $filename, $extension) = explode('.',$entry); |
532 | - if ( $extension != 'xml' ) continue; |
|
627 | + if ( $extension != 'xml' ) |
|
628 | + { |
|
629 | + continue; |
|
630 | + } |
|
533 | 631 | try { |
534 | 632 | // import will skip invalid files |
535 | 633 | importexport_definitions_bo::import( $file ); |
536 | - } catch (Exception $e) { |
|
634 | + } |
|
635 | + catch (Exception $e) { |
|
537 | 636 | error_log(__CLASS__.__FUNCTION__. " import $appname definitions: " . $e->getMessage()); |
538 | 637 | } |
539 | 638 | } |
540 | 639 | $d->close(); |
541 | 640 | } |
542 | 641 | |
543 | - public static function guess_filetype( $_file ) { |
|
642 | + public static function guess_filetype( $_file ) |
|
643 | + { |
|
544 | 644 | |
545 | 645 | } |
546 | 646 | |
@@ -551,7 +651,8 @@ discard block |
||
551 | 651 | * @param string $_type {import | export | all} |
552 | 652 | * @return boolean |
553 | 653 | */ |
554 | - public static function has_definitions( $_appname = 'all', $_type = 'all' ) { |
|
654 | + public static function has_definitions( $_appname = 'all', $_type = 'all' ) |
|
655 | + { |
|
555 | 656 | $definitions = Api\Cache::getSession( |
556 | 657 | __CLASS__, |
557 | 658 | 'has_definitions', |
@@ -565,27 +666,36 @@ discard block |
||
565 | 666 | // Testing: Comment out cache call above, use this |
566 | 667 | //$definitions = self::_has_definitions($appnames, $types); |
567 | 668 | |
568 | - foreach($definitions as $appname => $_types) { |
|
569 | - if(!in_array($appname, $appnames)) unset($definitions[$appname]); |
|
669 | + foreach($definitions as $appname => $_types) |
|
670 | + { |
|
671 | + if(!in_array($appname, $appnames)) |
|
672 | + { |
|
673 | + unset($definitions[$appname]); |
|
674 | + } |
|
570 | 675 | } |
571 | - foreach($definitions as $appname => $_types) { |
|
676 | + foreach($definitions as $appname => $_types) |
|
677 | + { |
|
572 | 678 | $definitions[$appname] = array_intersect_key($definitions[$appname], array_flip($types)); |
573 | 679 | } |
574 | 680 | return !empty($definitions[$appname]); |
575 | 681 | } |
576 | 682 | |
577 | 683 | // Api\Cache needs this public |
578 | - public static function _has_definitions(Array $appnames, Array $types) { |
|
684 | + public static function _has_definitions(Array $appnames, Array $types) |
|
685 | + { |
|
579 | 686 | $def = new importexport_definitions_bo(array('application'=>$appnames, 'type' => $types)); |
580 | 687 | $list = array(); |
581 | - foreach((array)$def->get_definitions() as $id) { |
|
688 | + foreach((array)$def->get_definitions() as $id) |
|
689 | + { |
|
582 | 690 | // Need to instanciate it to check, but if the user doesn't have permission, it throws an exception |
583 | 691 | try { |
584 | 692 | $definition = new importexport_definition($id); |
585 | - if($def->is_permitted($definition->get_record_array())) { |
|
693 | + if($def->is_permitted($definition->get_record_array())) |
|
694 | + { |
|
586 | 695 | $list[$definition->application][$definition->type][] = $id; |
587 | 696 | } |
588 | - } catch (Exception $e) { |
|
697 | + } |
|
698 | + catch (Exception $e) { |
|
589 | 699 | // That one doesn't work, keep going |
590 | 700 | } |
591 | 701 | $definition = null; |
@@ -614,13 +724,22 @@ discard block |
||
614 | 724 | $plugin = is_object($plugin_name) ? $plugin_name : new $plugin_name(); |
615 | 725 | $plugin_name = get_class($plugin); |
616 | 726 | |
617 | - if($record_classname == null) $record_classname = $plugin::get_egw_record_class(); |
|
618 | - if(!class_exists($record_classname)) throw new Exception('Bad class name ' . $record_classname); |
|
727 | + if($record_classname == null) |
|
728 | + { |
|
729 | + $record_classname = $plugin::get_egw_record_class(); |
|
730 | + } |
|
731 | + if(!class_exists($record_classname)) |
|
732 | + { |
|
733 | + throw new Exception('Bad class name ' . $record_classname); |
|
734 | + } |
|
619 | 735 | |
620 | 736 | if(!$wizard_plugin) |
621 | 737 | { |
622 | 738 | $wizard_name = $app_name . '_wizard_' . str_replace($app_name . '_', '', $plugin_name); |
623 | - if(!class_exists($wizard_name)) throw new Exception('Bad wizard name ' . $wizard_name); |
|
739 | + if(!class_exists($wizard_name)) |
|
740 | + { |
|
741 | + throw new Exception('Bad wizard name ' . $wizard_name); |
|
742 | + } |
|
624 | 743 | $wizard_plugin = new $wizard_name; |
625 | 744 | } |
626 | 745 | } |
@@ -640,7 +759,10 @@ discard block |
||
640 | 759 | foreach($record_classname::$types as $type => $type_fields) |
641 | 760 | { |
642 | 761 | // Only these for now, until filter methods for others are figured out |
643 | - if(!in_array($type, array('select','select-cat','select-account','date','date-time'))) continue; |
|
762 | + if(!in_array($type, array('select','select-cat','select-account','date','date-time'))) |
|
763 | + { |
|
764 | + continue; |
|
765 | + } |
|
644 | 766 | foreach($type_fields as $field_name) |
645 | 767 | { |
646 | 768 | $fields[$field_name] = array( |
@@ -658,14 +780,18 @@ discard block |
||
658 | 780 | $fields['#'.$field_name] = $settings; |
659 | 781 | } |
660 | 782 | |
661 | - foreach($fields as $field_name => &$settings) { |
|
783 | + foreach($fields as $field_name => &$settings) |
|
784 | + { |
|
662 | 785 | // Can't really filter on these (or at least no generic, sane way figured out yet) |
663 | 786 | if(!is_array($settings) || in_array($settings['type'], array('text','button', 'label','url','url-email','url-phone','htmlarea'))) |
664 | 787 | { |
665 | 788 | unset($fields[$field_name]); |
666 | 789 | continue; |
667 | 790 | } |
668 | - if($settings['type'] == 'radio') $settings['type'] = 'select'; |
|
791 | + if($settings['type'] == 'radio') |
|
792 | + { |
|
793 | + $settings['type'] = 'select'; |
|
794 | + } |
|
669 | 795 | switch($settings['type']) |
670 | 796 | { |
671 | 797 | case 'checkbox': |
@@ -35,6 +35,7 @@ discard block |
||
35 | 35 | * reads record from backend if identifier is given. |
36 | 36 | * |
37 | 37 | * @param string $_identifier |
38 | + * @return void |
|
38 | 39 | */ |
39 | 40 | public function __construct( $_identifier='' ); |
40 | 41 | |
@@ -50,6 +51,7 @@ discard block |
||
50 | 51 | * |
51 | 52 | * @param string $_attribute_name |
52 | 53 | * @param data $data |
54 | + * @return void |
|
53 | 55 | */ |
54 | 56 | public function __set($_attribute_name, $data); |
55 | 57 | |
@@ -126,6 +128,7 @@ discard block |
||
126 | 128 | /** |
127 | 129 | * destructor |
128 | 130 | * |
131 | + * @return void |
|
129 | 132 | */ |
130 | 133 | public function __destruct(); |
131 | 134 |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * |
37 | 37 | * @param string $_identifier |
38 | 38 | */ |
39 | - public function __construct( $_identifier='' ); |
|
39 | + public function __construct($_identifier = ''); |
|
40 | 40 | |
41 | 41 | /** |
42 | 42 | * magic method to set attributes of record |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * |
98 | 98 | * @return string identifier |
99 | 99 | */ |
100 | - public function save ( $_dst_identifier ); |
|
100 | + public function save($_dst_identifier); |
|
101 | 101 | |
102 | 102 | /** |
103 | 103 | * copys current record to record identified by $_dst_identifier |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * @param string $_dst_identifier |
106 | 106 | * @return string dst_identifier |
107 | 107 | */ |
108 | - public function copy ( $_dst_identifier ); |
|
108 | + public function copy($_dst_identifier); |
|
109 | 109 | |
110 | 110 | /** |
111 | 111 | * moves current record to record identified by $_dst_identifier |
@@ -114,14 +114,14 @@ discard block |
||
114 | 114 | * @param string $_dst_identifier |
115 | 115 | * @return string dst_identifier |
116 | 116 | */ |
117 | - public function move ( $_dst_identifier ); |
|
117 | + public function move($_dst_identifier); |
|
118 | 118 | |
119 | 119 | /** |
120 | 120 | * delets current record from backend |
121 | 121 | * @return void |
122 | 122 | * |
123 | 123 | */ |
124 | - public function delete (); |
|
124 | + public function delete(); |
|
125 | 125 | |
126 | 126 | /** |
127 | 127 | * destructor |
@@ -54,7 +54,7 @@ |
||
54 | 54 | * destructor |
55 | 55 | * |
56 | 56 | * @return |
57 | - */ |
|
57 | + void |
|
58 | 58 | public function __destruct( ); |
59 | 59 | |
60 | 60 | } // end of iface_export_record |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * @param array $_options options for specific backends |
34 | 34 | * @return bool |
35 | 35 | */ |
36 | - public function __construct( $_stream, array $_options ); |
|
36 | + public function __construct($_stream, array $_options); |
|
37 | 37 | |
38 | 38 | /** |
39 | 39 | * exports a record into resource of handle |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * @param object of interface egw_record _record |
42 | 42 | * @return bool |
43 | 43 | */ |
44 | - public function export_record( importexport_iface_egw_record $_record ); |
|
44 | + public function export_record(importexport_iface_egw_record $_record); |
|
45 | 45 | |
46 | 46 | /** |
47 | 47 | * Retruns total number of exported records. |
@@ -29,8 +29,8 @@ |
||
29 | 29 | /** |
30 | 30 | * imports entries according to given definition object. |
31 | 31 | * |
32 | - * @param stram $_stram |
|
33 | - * @param definition $_definition |
|
32 | + * @param stram $_stream |
|
33 | + * @param importexport_definition $_definition |
|
34 | 34 | * @return int number of successful imports |
35 | 35 | */ |
36 | 36 | public function import( $_stream, importexport_definition $_definition ); |
@@ -88,33 +88,33 @@ |
||
88 | 88 | public function get_selectors_etpl(); |
89 | 89 | |
90 | 90 | /** |
91 | - * Returns errors that were encountered during importing |
|
92 | - * Maximum of one error message per record, but you can concatenate them if you need to |
|
93 | - * |
|
94 | - * @return Array ( |
|
95 | - * record_# => error message |
|
96 | - * ) |
|
97 | - */ |
|
91 | + * Returns errors that were encountered during importing |
|
92 | + * Maximum of one error message per record, but you can concatenate them if you need to |
|
93 | + * |
|
94 | + * @return Array ( |
|
95 | + * record_# => error message |
|
96 | + * ) |
|
97 | + */ |
|
98 | 98 | public function get_errors(); |
99 | 99 | |
100 | 100 | /** |
101 | - * Returns warnings that were encountered during importing |
|
102 | - * Maximum of one warning message per record, but you can concatenate them if you need to |
|
103 | - * |
|
104 | - * @return Array ( |
|
105 | - * record_# => warning message |
|
106 | - * ) |
|
107 | - */ |
|
101 | + * Returns warnings that were encountered during importing |
|
102 | + * Maximum of one warning message per record, but you can concatenate them if you need to |
|
103 | + * |
|
104 | + * @return Array ( |
|
105 | + * record_# => warning message |
|
106 | + * ) |
|
107 | + */ |
|
108 | 108 | public function get_warnings(); |
109 | 109 | |
110 | 110 | /** |
111 | - * Returns a list of actions taken, and the number of records for that action. |
|
112 | - * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin. |
|
113 | - * |
|
114 | - * @return Array ( |
|
115 | - * action => record count |
|
116 | - * ) |
|
117 | - */ |
|
111 | + * Returns a list of actions taken, and the number of records for that action. |
|
112 | + * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin. |
|
113 | + * |
|
114 | + * @return Array ( |
|
115 | + * action => record count |
|
116 | + * ) |
|
117 | + */ |
|
118 | 118 | public function get_results(); |
119 | 119 | |
120 | 120 | } // end of iface_export_plugin |
@@ -24,7 +24,8 @@ |
||
24 | 24 | * So this interface just garanties the interaction with userinterfaces. It |
25 | 25 | * has nothing to do with datatypes. |
26 | 26 | */ |
27 | -interface importexport_iface_import_plugin { |
|
27 | +interface importexport_iface_import_plugin |
|
28 | +{ |
|
28 | 29 | |
29 | 30 | /** |
30 | 31 | * imports entries according to given definition object. |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * @param definition $_definition |
34 | 34 | * @return int number of successful imports |
35 | 35 | */ |
36 | - public function import( $_stream, importexport_definition $_definition ); |
|
36 | + public function import($_stream, importexport_definition $_definition); |
|
37 | 37 | |
38 | 38 | /** |
39 | 39 | * Reads entries, and presents them back as they will be understood |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * preserv => array, |
80 | 80 | * ) |
81 | 81 | */ |
82 | - public function get_options_etpl(importexport_definition &$definition=null); |
|
82 | + public function get_options_etpl(importexport_definition &$definition = null); |
|
83 | 83 | |
84 | 84 | /** |
85 | 85 | * returns etemplate name for slectors of this plugin |
@@ -33,7 +33,7 @@ |
||
33 | 33 | * cleanup |
34 | 34 | * |
35 | 35 | * @return |
36 | - */ |
|
36 | + void |
|
37 | 37 | public function __destruct( ); |
38 | 38 | |
39 | 39 | /** |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | * @param array $_options options for specific backends |
28 | 28 | * @return bool |
29 | 29 | */ |
30 | - public function __construct( $_stream, array $_options ); |
|
30 | + public function __construct($_stream, array $_options); |
|
31 | 31 | |
32 | 32 | /** |
33 | 33 | * cleanup |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @param string _position may be: {first|last|next|previous|somenumber} |
43 | 43 | * @return bool |
44 | 44 | */ |
45 | - public function get_record( $_position = 'next' ); |
|
45 | + public function get_record($_position = 'next'); |
|
46 | 46 | |
47 | 47 | /** |
48 | 48 | * Retruns total number of records for the open resource. |
@@ -137,8 +137,8 @@ discard block |
||
137 | 137 | /** |
138 | 138 | * updates $this->record |
139 | 139 | * |
140 | - * @param mixed $_position |
|
141 | - * @return bool |
|
140 | + * @param string $_position |
|
141 | + * @return null|false |
|
142 | 142 | */ |
143 | 143 | private function get_raw_record( $_position = 'next' ) { |
144 | 144 | switch ($_position) { |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | /** |
245 | 245 | * does conversions according to $this->conversion |
246 | 246 | * |
247 | - * @return bool |
|
247 | + * @return boolean|null |
|
248 | 248 | */ |
249 | 249 | protected function do_conversions() { |
250 | 250 | if ( $record = importexport_helper_functions::conversion( $this->record, $this->conversion, $this->conversion_class )) { |
@@ -264,7 +264,7 @@ |
||
264 | 264 | * |
265 | 265 | * @return string warnings, if any |
266 | 266 | */ |
267 | - public static function convert(Array &$record, Array $fields = array(), $appname = null, Array $selects = array(), $format=0) { |
|
267 | + public static function convert(array &$record, array $fields = array(), $appname = null, array $selects = array(), $format=0) { |
|
268 | 268 | $warnings = array(); |
269 | 269 | |
270 | 270 | // Automatic conversions |
@@ -83,10 +83,10 @@ discard block |
||
83 | 83 | * @param string $_resource resource containing data. May be each valid php-stream |
84 | 84 | * @param array $_options options for the resource array with keys: charset and fieldsep |
85 | 85 | */ |
86 | - public function __construct( $_resource, array $_options ) { |
|
86 | + public function __construct($_resource, array $_options) { |
|
87 | 87 | $this->resource = $_resource; |
88 | 88 | $this->csv_fieldsep = $_options['fieldsep']; |
89 | - if($_options['charset'] == 'user') $_options['charset'] = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset']; |
|
89 | + if ($_options['charset'] == 'user') $_options['charset'] = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset']; |
|
90 | 90 | $this->csv_charset = $_options['charset']; |
91 | 91 | return; |
92 | 92 | } // end of member function __construct |
@@ -103,20 +103,20 @@ discard block |
||
103 | 103 | * @param mixed _position may be: {current|first|last|next|previous|somenumber} |
104 | 104 | * @return mixed array with data / false if no furtor records |
105 | 105 | */ |
106 | - public function get_record( $_position = 'next' ) { |
|
106 | + public function get_record($_position = 'next') { |
|
107 | 107 | |
108 | - if ($this->get_raw_record( $_position ) === false) { |
|
108 | + if ($this->get_raw_record($_position) === false) { |
|
109 | 109 | return false; |
110 | 110 | } |
111 | 111 | |
112 | 112 | // skip empty records |
113 | - if( count( array_unique( $this->record ) ) < 2 ) return $this->get_record( $_position ); |
|
113 | + if (count(array_unique($this->record)) < 2) return $this->get_record($_position); |
|
114 | 114 | |
115 | - if ( !empty( $this->conversion ) ) { |
|
115 | + if (!empty($this->conversion)) { |
|
116 | 116 | $this->do_conversions(); |
117 | 117 | } |
118 | 118 | |
119 | - if ( !empty( $this->mapping ) ) { |
|
119 | + if (!empty($this->mapping)) { |
|
120 | 120 | $this->do_fieldmapping(); |
121 | 121 | } |
122 | 122 | |
@@ -128,9 +128,9 @@ discard block |
||
128 | 128 | * |
129 | 129 | * @param int $_numToSkip |
130 | 130 | */ |
131 | - public function skip_records( $_numToSkip ) { |
|
132 | - while ( (int)$_numToSkip-- !== 0 ) { |
|
133 | - fgetcsv( $this->resource, self::csv_max_linelength, $this->csv_fieldsep); |
|
131 | + public function skip_records($_numToSkip) { |
|
132 | + while ((int)$_numToSkip-- !== 0) { |
|
133 | + fgetcsv($this->resource, self::csv_max_linelength, $this->csv_fieldsep); |
|
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * @param mixed $_position |
141 | 141 | * @return bool |
142 | 142 | */ |
143 | - private function get_raw_record( $_position = 'next' ) { |
|
143 | + private function get_raw_record($_position = 'next') { |
|
144 | 144 | switch ($_position) { |
145 | 145 | case 'current' : |
146 | 146 | if ($this->current_position == 0) { |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | } |
155 | 155 | |
156 | 156 | case 'next' : |
157 | - $csv_data = fgetcsv( $this->resource, self::csv_max_linelength, $this->csv_fieldsep); |
|
157 | + $csv_data = fgetcsv($this->resource, self::csv_max_linelength, $this->csv_fieldsep); |
|
158 | 158 | if (!is_array($csv_data)) { |
159 | 159 | return false; |
160 | 160 | } |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | $this->record = array(); |
236 | 236 | foreach ($this->mapping as $cvs_idx => $new_idx) |
237 | 237 | { |
238 | - if( $new_idx == '' ) continue; |
|
238 | + if ($new_idx == '') continue; |
|
239 | 239 | $this->record[$new_idx] = $record[$cvs_idx]; |
240 | 240 | } |
241 | 241 | return true; |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | * @return bool |
248 | 248 | */ |
249 | 249 | protected function do_conversions() { |
250 | - if ( $record = importexport_helper_functions::conversion( $this->record, $this->conversion, $this->conversion_class )) { |
|
250 | + if ($record = importexport_helper_functions::conversion($this->record, $this->conversion, $this->conversion_class)) { |
|
251 | 251 | $this->record = $record; |
252 | 252 | return; |
253 | 253 | } |
@@ -264,25 +264,25 @@ discard block |
||
264 | 264 | * |
265 | 265 | * @return string warnings, if any |
266 | 266 | */ |
267 | - public static function convert(Array &$record, Array $fields = array(), $appname = null, Array $selects = array(), $format=0) { |
|
267 | + public static function convert(Array &$record, Array $fields = array(), $appname = null, Array $selects = array(), $format = 0) { |
|
268 | 268 | $warnings = array(); |
269 | 269 | |
270 | 270 | // Automatic conversions |
271 | - if($appname) { |
|
271 | + if ($appname) { |
|
272 | 272 | |
273 | 273 | // Load translations |
274 | 274 | Api\Translation::add_app($appname); |
275 | 275 | |
276 | - if(!self::$cf_parse_cache[$appname]) { |
|
276 | + if (!self::$cf_parse_cache[$appname]) { |
|
277 | 277 | $c_fields = importexport_export_csv::convert_parse_custom_fields($appname, $selects, $links, $methods); |
278 | 278 | self::$cf_parse_cache[$appname] = array($c_fields, $selects, $links, $methods); |
279 | 279 | } |
280 | 280 | list($c_fields, $c_selects, $links, $methods) = self::$cf_parse_cache[$appname]; |
281 | 281 | |
282 | 282 | // Add in any fields that are keys to another app |
283 | - foreach((array)$fields['links'] as $link_field => $app) |
|
283 | + foreach ((array)$fields['links'] as $link_field => $app) |
|
284 | 284 | { |
285 | - if(is_numeric($link_field)) continue; |
|
285 | + if (is_numeric($link_field)) continue; |
|
286 | 286 | $links[$link_field] = $app; |
287 | 287 | // Set it as a normal link field |
288 | 288 | $fields['links'][] = $link_field; |
@@ -290,9 +290,9 @@ discard block |
||
290 | 290 | } |
291 | 291 | |
292 | 292 | // Not quite a recursive merge, since only one level |
293 | - foreach($fields as $type => &$list) |
|
293 | + foreach ($fields as $type => &$list) |
|
294 | 294 | { |
295 | - if($c_fields[$type]) { |
|
295 | + if ($c_fields[$type]) { |
|
296 | 296 | $list = array_merge($c_fields[$type], $list); |
297 | 297 | unset($c_fields[$type]); |
298 | 298 | } |
@@ -300,26 +300,26 @@ discard block |
||
300 | 300 | $fields += $c_fields; |
301 | 301 | $selects += $c_selects; |
302 | 302 | } |
303 | - if($fields) { |
|
304 | - foreach((array)$fields['select'] as $name) { |
|
303 | + if ($fields) { |
|
304 | + foreach ((array)$fields['select'] as $name) { |
|
305 | 305 | $record[$name] = static::find_select_key($record[$name], $selects[$name]); |
306 | 306 | } |
307 | 307 | |
308 | - foreach((array)$fields['links'] as $name) { |
|
309 | - if($record[$name] && $links[$name]) |
|
308 | + foreach ((array)$fields['links'] as $name) { |
|
309 | + if ($record[$name] && $links[$name]) |
|
310 | 310 | { |
311 | 311 | // Primary key to another app, not a link |
312 | 312 | // Text - search for a matching record |
313 | - if(!is_numeric($record[$name])) |
|
313 | + if (!is_numeric($record[$name])) |
|
314 | 314 | { |
315 | 315 | $results = Link::query($links[$name], $record[$name]); |
316 | - if(count($results) >= 1) |
|
316 | + if (count($results) >= 1) |
|
317 | 317 | { |
318 | 318 | // More than 1 result. Check for exact match |
319 | 319 | $exact_count = 0; |
320 | - foreach($results as $id => $title) |
|
320 | + foreach ($results as $id => $title) |
|
321 | 321 | { |
322 | - if($title == $record[$name]) |
|
322 | + if ($title == $record[$name]) |
|
323 | 323 | { |
324 | 324 | $exact_count++; |
325 | 325 | $app_id = $id; |
@@ -328,11 +328,11 @@ discard block |
||
328 | 328 | unset($results[$id]); |
329 | 329 | } |
330 | 330 | // Too many exact matches, or none good enough |
331 | - if($exact_count > 1 || count($results) == 0) |
|
331 | + if ($exact_count > 1 || count($results) == 0) |
|
332 | 332 | { |
333 | 333 | $warnings[] = lang('Unable to link to %1 "%2"', |
334 | 334 | lang($links[$name]), $record[$name]). |
335 | - ' - ' .lang('too many matches'); |
|
335 | + ' - '.lang('too many matches'); |
|
336 | 336 | continue; |
337 | 337 | } |
338 | 338 | elseif ($exact_count == 1) |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | { |
346 | 346 | $warnings[] = lang('Unable to link to %1 "%2"', |
347 | 347 | lang($links[$name]), $record[$name]). |
348 | - ' - ' . lang('no matches'); |
|
348 | + ' - '.lang('no matches'); |
|
349 | 349 | continue; |
350 | 350 | } else { |
351 | 351 | $record[$name] = key($results); |
@@ -353,17 +353,17 @@ discard block |
||
353 | 353 | } |
354 | 354 | } |
355 | 355 | } |
356 | - foreach((array)$fields['select-account'] as $name) { |
|
356 | + foreach ((array)$fields['select-account'] as $name) { |
|
357 | 357 | // Compare against null to deal with empty arrays |
358 | 358 | if ($record[$name]) { |
359 | 359 | // Automatically handle text owner without explicit translation |
360 | 360 | $new_owner = importexport_helper_functions::account_name2id($record[$name]); |
361 | - if(count($new_owner) != count(explode(',',$record[$name]))) |
|
361 | + if (count($new_owner) != count(explode(',', $record[$name]))) |
|
362 | 362 | { |
363 | 363 | // Unable to parse value into account |
364 | - $warnings[] = $name . ': ' .lang('%1 is not a known user or group', $record[$name]); |
|
364 | + $warnings[] = $name.': '.lang('%1 is not a known user or group', $record[$name]); |
|
365 | 365 | } |
366 | - if($new_owner != '') { |
|
366 | + if ($new_owner != '') { |
|
367 | 367 | $record[$name] = $new_owner; |
368 | 368 | } else { |
369 | 369 | // Clear it to prevent trouble later on |
@@ -371,24 +371,24 @@ discard block |
||
371 | 371 | } |
372 | 372 | } |
373 | 373 | } |
374 | - foreach((array)$fields['select-bool'] as $name) { |
|
375 | - if($record[$name] != null && $record[$name] != '') { |
|
374 | + foreach ((array)$fields['select-bool'] as $name) { |
|
375 | + if ($record[$name] != null && $record[$name] != '') { |
|
376 | 376 | $record[$name] = (strtolower($record[$name]) == strtolower(lang('Yes')) || $record[$name] == '1' ? 1 : 0); |
377 | 377 | } |
378 | 378 | } |
379 | - foreach((array)$fields['date-time'] as $name) { |
|
379 | + foreach ((array)$fields['date-time'] as $name) { |
|
380 | 380 | if (isset($record[$name]) && !is_numeric($record[$name]) && strlen(trim($record[$name])) > 0) |
381 | 381 | { |
382 | 382 | // Need to handle format first |
383 | - if($format == 1) |
|
383 | + if ($format == 1) |
|
384 | 384 | { |
385 | 385 | $formatted = Api\DateTime::createFromFormat( |
386 | - '!'.Api\DateTime::$user_dateformat . ' ' .Api\DateTime::$user_timeformat, |
|
386 | + '!'.Api\DateTime::$user_dateformat.' '.Api\DateTime::$user_timeformat, |
|
387 | 387 | $record[$name], |
388 | 388 | Api\DateTime::$user_timezone |
389 | 389 | ); |
390 | 390 | |
391 | - if(!$formatted && $errors = Api\DateTime::getLastErrors()) |
|
391 | + if (!$formatted && $errors = Api\DateTime::getLastErrors()) |
|
392 | 392 | { |
393 | 393 | // Try again, without time |
394 | 394 | $formatted = Api\DateTime::createFromFormat( |
@@ -397,70 +397,70 @@ discard block |
||
397 | 397 | Api\DateTime::$user_timezone |
398 | 398 | ); |
399 | 399 | |
400 | - if(!$formatted && $errors = Api\DateTime::getLastErrors()) |
|
400 | + if (!$formatted && $errors = Api\DateTime::getLastErrors()) |
|
401 | 401 | { |
402 | 402 | // Try again, anything goes |
403 | 403 | try { |
404 | 404 | $formatted = new Api\DateTime($record[$name]); |
405 | 405 | } catch (Exception $e) { |
406 | - $warnings[] = $name.': ' . $e->getMessage() . "\n" . |
|
407 | - 'Format: '.'!'.Api\DateTime::$user_dateformat . ' ' .Api\DateTime::$user_timeformat; |
|
406 | + $warnings[] = $name.': '.$e->getMessage()."\n". |
|
407 | + 'Format: '.'!'.Api\DateTime::$user_dateformat.' '.Api\DateTime::$user_timeformat; |
|
408 | 408 | continue; |
409 | 409 | } |
410 | 410 | $errors = Api\DateTime::getLastErrors(); |
411 | - foreach($errors['errors'] as $char => $msg) |
|
411 | + foreach ($errors['errors'] as $char => $msg) |
|
412 | 412 | { |
413 | 413 | $warnings[] = "$name: [$char] $msg\n". |
414 | - 'Format: '.'!'.Api\DateTime::$user_dateformat . ' ' .Api\DateTime::$user_timeformat; |
|
414 | + 'Format: '.'!'.Api\DateTime::$user_dateformat.' '.Api\DateTime::$user_timeformat; |
|
415 | 415 | } |
416 | 416 | } |
417 | 417 | } |
418 | - if($formatted) |
|
418 | + if ($formatted) |
|
419 | 419 | { |
420 | 420 | $record[$name] = $formatted->getTimestamp(); |
421 | 421 | // Timestamp is apparently in server time, but apps will do the same conversion |
422 | - $record[$name] = Api\DateTime::server2user($record[$name],'ts'); |
|
422 | + $record[$name] = Api\DateTime::server2user($record[$name], 'ts'); |
|
423 | 423 | } |
424 | 424 | } |
425 | 425 | |
426 | - if(is_array(self::$cf_parse_cache[$appname][0]['date-time']) && |
|
426 | + if (is_array(self::$cf_parse_cache[$appname][0]['date-time']) && |
|
427 | 427 | in_array($name, self::$cf_parse_cache[$appname][0]['date-time'])) { |
428 | 428 | // Custom fields stored in a particular format (from customfields_widget) |
429 | 429 | $record[$name] = date('Y-m-d H:i:s', $record[$name]); |
430 | 430 | } |
431 | 431 | } |
432 | - if(array_key_exists($name, $record) && strlen(trim($record[$name])) == 0) |
|
432 | + if (array_key_exists($name, $record) && strlen(trim($record[$name])) == 0) |
|
433 | 433 | { |
434 | 434 | $record[$name] = null; |
435 | 435 | } |
436 | 436 | } |
437 | - foreach((array)$fields['date'] as $name) { |
|
437 | + foreach ((array)$fields['date'] as $name) { |
|
438 | 438 | if (isset($record[$name]) && !is_numeric($record[$name]) && strlen(trim($record[$name])) > 0) |
439 | 439 | { |
440 | 440 | // Need to handle format first |
441 | - if($format == 1) |
|
441 | + if ($format == 1) |
|
442 | 442 | { |
443 | 443 | $formatted = Api\DateTime::createFromFormat('!'.Api\DateTime::$user_dateformat, $record[$name]); |
444 | - if($formatted && $errors = Api\DateTime::getLastErrors() && $errors['error_count'] == 0) |
|
444 | + if ($formatted && $errors = Api\DateTime::getLastErrors() && $errors['error_count'] == 0) |
|
445 | 445 | { |
446 | 446 | $record[$name] = $formatted->getTimestamp(); |
447 | 447 | } |
448 | 448 | } |
449 | - $record[$name] = Api\DateTime::server2user($record[$name],'ts'); |
|
450 | - if(is_array(self::$cf_parse_cache[$appname][0]['date']) && |
|
449 | + $record[$name] = Api\DateTime::server2user($record[$name], 'ts'); |
|
450 | + if (is_array(self::$cf_parse_cache[$appname][0]['date']) && |
|
451 | 451 | in_array($name, self::$cf_parse_cache[$appname][0]['date'])) { |
452 | 452 | // Custom fields stored in a particular format (from customfields_widget) |
453 | 453 | $record[$name] = date('Y-m-d', $record[$name]); |
454 | 454 | } |
455 | 455 | } |
456 | - if(array_key_exists($name, $record) && strlen(trim($record[$name])) == 0) |
|
456 | + if (array_key_exists($name, $record) && strlen(trim($record[$name])) == 0) |
|
457 | 457 | { |
458 | 458 | $record[$name] = null; |
459 | 459 | } |
460 | 460 | } |
461 | - foreach((array)$fields['float'] as $name) |
|
461 | + foreach ((array)$fields['float'] as $name) |
|
462 | 462 | { |
463 | - if($record[$name] != null && $record[$name] != '') { |
|
463 | + if ($record[$name] != null && $record[$name] != '') { |
|
464 | 464 | $dec_point = $GLOBALS['egw_info']['user']['preferences']['common']['number_format'][0]; |
465 | 465 | if (empty($dec_point)) $dec_point = '.'; |
466 | 466 | $record[$name] = floatval(str_replace($dec_point, '.', preg_replace('/[^\d'.preg_quote($dec_point).']/', '', $record[$name]))); |
@@ -468,23 +468,23 @@ discard block |
||
468 | 468 | } |
469 | 469 | |
470 | 470 | // Some custom methods for conversion |
471 | - foreach((array)$methods as $name => $method) { |
|
472 | - if($record[$name]) $record[$name] = ExecMethod($method, $record[$name]); |
|
471 | + foreach ((array)$methods as $name => $method) { |
|
472 | + if ($record[$name]) $record[$name] = ExecMethod($method, $record[$name]); |
|
473 | 473 | } |
474 | 474 | |
475 | 475 | // cat_name2id will use currentapp to create new categories |
476 | 476 | $current_app = $GLOBALS['egw_info']['flags']['currentapp']; |
477 | - if($appname) { |
|
477 | + if ($appname) { |
|
478 | 478 | $GLOBALS['egw_info']['flags']['currentapp'] = $appname; |
479 | 479 | } |
480 | - $categories = new Api\Categories('',$appname); |
|
481 | - foreach((array)$fields['select-cat'] as $name) { |
|
482 | - if($record[$name]) { |
|
480 | + $categories = new Api\Categories('', $appname); |
|
481 | + foreach ((array)$fields['select-cat'] as $name) { |
|
482 | + if ($record[$name]) { |
|
483 | 483 | // Only parse name if it needs it |
484 | - if($format == 1) |
|
484 | + if ($format == 1) |
|
485 | 485 | { |
486 | - $existing_cat = $categories->exists('all',$record[$name]); |
|
487 | - if($existing_cat) |
|
486 | + $existing_cat = $categories->exists('all', $record[$name]); |
|
487 | + if ($existing_cat) |
|
488 | 488 | { |
489 | 489 | $cat_id = $existing_cat; |
490 | 490 | } |
@@ -493,14 +493,14 @@ discard block |
||
493 | 493 | $cat_id = importexport_helper_functions::cat_name2id($record[$name]); |
494 | 494 | } |
495 | 495 | // Don't clear it if it wasn't found |
496 | - if($cat_id) $record[$name] = $cat_id; |
|
496 | + if ($cat_id) $record[$name] = $cat_id; |
|
497 | 497 | } |
498 | 498 | } |
499 | 499 | } |
500 | 500 | $GLOBALS['egw_info']['flags']['currentapp'] = $current_app; |
501 | 501 | } |
502 | 502 | |
503 | - return implode("\n",$warnings); |
|
503 | + return implode("\n", $warnings); |
|
504 | 504 | } |
505 | 505 | |
506 | 506 | /** |
@@ -514,36 +514,36 @@ discard block |
||
514 | 514 | */ |
515 | 515 | protected static function find_select_key($record_value, $selects) |
516 | 516 | { |
517 | - if($record_value != null && is_array($selects)) { |
|
518 | - if(is_array($record_value) || is_string($record_value) && strpos($record_value, ',') !== FALSE) |
|
517 | + if ($record_value != null && is_array($selects)) { |
|
518 | + if (is_array($record_value) || is_string($record_value) && strpos($record_value, ',') !== FALSE) |
|
519 | 519 | { |
520 | 520 | // Array, or CSV |
521 | 521 | $key = array(); |
522 | - $subs = explode(',',$record_value); |
|
523 | - for($sub_index = 0; $sub_index < count($subs); $sub_index++) |
|
522 | + $subs = explode(',', $record_value); |
|
523 | + for ($sub_index = 0; $sub_index < count($subs); $sub_index++) |
|
524 | 524 | { |
525 | 525 | $sub_key = static::find_select_key(trim($subs[$sub_index]), $selects); |
526 | - if(!$sub_key) |
|
526 | + if (!$sub_key) |
|
527 | 527 | { |
528 | - $sub_key = static::find_select_key(trim($subs[$sub_index]).','.trim($subs[$sub_index+1]), $selects); |
|
529 | - if($sub_key) $sub_index++; |
|
528 | + $sub_key = static::find_select_key(trim($subs[$sub_index]).','.trim($subs[$sub_index + 1]), $selects); |
|
529 | + if ($sub_key) $sub_index++; |
|
530 | 530 | } |
531 | - if($sub_key) |
|
531 | + if ($sub_key) |
|
532 | 532 | { |
533 | 533 | $key[] = $sub_key; |
534 | 534 | } |
535 | 535 | } |
536 | 536 | return $key; |
537 | 537 | } |
538 | - $key = array_search(strtolower($record_value), array_map('strtolower',$selects)); |
|
539 | - if($key !== false) |
|
538 | + $key = array_search(strtolower($record_value), array_map('strtolower', $selects)); |
|
539 | + if ($key !== false) |
|
540 | 540 | { |
541 | 541 | $record_value = $key; |
542 | 542 | } |
543 | 543 | else |
544 | 544 | { |
545 | - $key = array_search(strtolower($record_value), array_map('strtolower',array_map('lang',$selects))); |
|
546 | - if($key !== false) $record_value = $key; |
|
545 | + $key = array_search(strtolower($record_value), array_map('strtolower', array_map('lang', $selects))); |
|
546 | + if ($key !== false) $record_value = $key; |
|
547 | 547 | } |
548 | 548 | } |
549 | 549 |
@@ -22,7 +22,9 @@ discard block |
||
22 | 22 | * @todo Throw away spechial chars and trim() entries ? |
23 | 23 | * @todo Check for XSS like userinput! (see common_functions) |
24 | 24 | */ |
25 | -class importexport_import_csv implements importexport_iface_import_record { //, Iterator { |
|
25 | +class importexport_import_csv implements importexport_iface_import_record |
|
26 | +{ |
|
27 | +//, Iterator { |
|
26 | 28 | |
27 | 29 | const csv_max_linelength = 8000; |
28 | 30 | |
@@ -83,10 +85,14 @@ discard block |
||
83 | 85 | * @param string $_resource resource containing data. May be each valid php-stream |
84 | 86 | * @param array $_options options for the resource array with keys: charset and fieldsep |
85 | 87 | */ |
86 | - public function __construct( $_resource, array $_options ) { |
|
88 | + public function __construct( $_resource, array $_options ) |
|
89 | + { |
|
87 | 90 | $this->resource = $_resource; |
88 | 91 | $this->csv_fieldsep = $_options['fieldsep']; |
89 | - if($_options['charset'] == 'user') $_options['charset'] = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset']; |
|
92 | + if($_options['charset'] == 'user') |
|
93 | + { |
|
94 | + $_options['charset'] = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset']; |
|
95 | + } |
|
90 | 96 | $this->csv_charset = $_options['charset']; |
91 | 97 | return; |
92 | 98 | } // end of member function __construct |
@@ -94,7 +100,8 @@ discard block |
||
94 | 100 | /** |
95 | 101 | * cleanup |
96 | 102 | */ |
97 | - public function __destruct( ) { |
|
103 | + public function __destruct( ) |
|
104 | + { |
|
98 | 105 | } // end of member function __destruct |
99 | 106 | |
100 | 107 | /** |
@@ -103,20 +110,27 @@ discard block |
||
103 | 110 | * @param mixed _position may be: {current|first|last|next|previous|somenumber} |
104 | 111 | * @return mixed array with data / false if no furtor records |
105 | 112 | */ |
106 | - public function get_record( $_position = 'next' ) { |
|
113 | + public function get_record( $_position = 'next' ) |
|
114 | + { |
|
107 | 115 | |
108 | - if ($this->get_raw_record( $_position ) === false) { |
|
116 | + if ($this->get_raw_record( $_position ) === false) |
|
117 | + { |
|
109 | 118 | return false; |
110 | 119 | } |
111 | 120 | |
112 | 121 | // skip empty records |
113 | - if( count( array_unique( $this->record ) ) < 2 ) return $this->get_record( $_position ); |
|
122 | + if( count( array_unique( $this->record ) ) < 2 ) |
|
123 | + { |
|
124 | + return $this->get_record( $_position ); |
|
125 | + } |
|
114 | 126 | |
115 | - if ( !empty( $this->conversion ) ) { |
|
127 | + if ( !empty( $this->conversion ) ) |
|
128 | + { |
|
116 | 129 | $this->do_conversions(); |
117 | 130 | } |
118 | 131 | |
119 | - if ( !empty( $this->mapping ) ) { |
|
132 | + if ( !empty( $this->mapping ) ) |
|
133 | + { |
|
120 | 134 | $this->do_fieldmapping(); |
121 | 135 | } |
122 | 136 | |
@@ -128,8 +142,10 @@ discard block |
||
128 | 142 | * |
129 | 143 | * @param int $_numToSkip |
130 | 144 | */ |
131 | - public function skip_records( $_numToSkip ) { |
|
132 | - while ( (int)$_numToSkip-- !== 0 ) { |
|
145 | + public function skip_records( $_numToSkip ) |
|
146 | + { |
|
147 | + while ( (int)$_numToSkip-- !== 0 ) |
|
148 | + { |
|
133 | 149 | fgetcsv( $this->resource, self::csv_max_linelength, $this->csv_fieldsep); |
134 | 150 | } |
135 | 151 | } |
@@ -140,22 +156,27 @@ discard block |
||
140 | 156 | * @param mixed $_position |
141 | 157 | * @return bool |
142 | 158 | */ |
143 | - private function get_raw_record( $_position = 'next' ) { |
|
144 | - switch ($_position) { |
|
159 | + private function get_raw_record( $_position = 'next' ) |
|
160 | + { |
|
161 | + switch ($_position) |
|
162 | + { |
|
145 | 163 | case 'current' : |
146 | - if ($this->current_position == 0) { |
|
164 | + if ($this->current_position == 0) |
|
165 | + { |
|
147 | 166 | return; |
148 | 167 | } |
149 | 168 | break; |
150 | 169 | case 'first' : |
151 | - if (!$this->current_position == 0) { |
|
170 | + if (!$this->current_position == 0) |
|
171 | + { |
|
152 | 172 | $this->current_position = 0; |
153 | 173 | rewind($this->resource); |
154 | 174 | } |
155 | 175 | |
156 | 176 | case 'next' : |
157 | 177 | $csv_data = fgetcsv( $this->resource, self::csv_max_linelength, $this->csv_fieldsep); |
158 | - if (!is_array($csv_data)) { |
|
178 | + if (!is_array($csv_data)) |
|
179 | + { |
|
159 | 180 | return false; |
160 | 181 | } |
161 | 182 | $this->current_position++; |
@@ -163,33 +184,41 @@ discard block |
||
163 | 184 | break; |
164 | 185 | |
165 | 186 | case 'previous' : |
166 | - if ($this->current_position < 2) { |
|
187 | + if ($this->current_position < 2) |
|
188 | + { |
|
167 | 189 | throw new Exception('Error: There is no previous record!'); |
168 | 190 | } |
169 | 191 | $final_position = --$this->current_position; |
170 | 192 | $this->current_position = 0; |
171 | 193 | rewind($this->resource); |
172 | - while ($this->current_position !== $final_position) { |
|
194 | + while ($this->current_position !== $final_position) |
|
195 | + { |
|
173 | 196 | $this->get_raw_record(); |
174 | 197 | } |
175 | 198 | break; |
176 | 199 | |
177 | 200 | case 'last' : |
178 | - while ($this->get_raw_record()) {} |
|
201 | + while ($this->get_raw_record()) |
|
202 | + { |
|
203 | +} |
|
179 | 204 | break; |
180 | 205 | |
181 | 206 | default: //somenumber |
182 | - if (!is_int($_position)) { |
|
207 | + if (!is_int($_position)) |
|
208 | + { |
|
183 | 209 | throw new Exception('Error: $position must be one of {current|first|last|next|previous} or an integer value'); |
184 | 210 | } |
185 | - if ($_position == $this->current_position) { |
|
211 | + if ($_position == $this->current_position) |
|
212 | + { |
|
186 | 213 | break; |
187 | 214 | } |
188 | - elseif ($_position < $this->current_position) { |
|
215 | + elseif ($_position < $this->current_position) |
|
216 | + { |
|
189 | 217 | $this->current_position = 0; |
190 | 218 | rewind($this->resource); |
191 | 219 | } |
192 | - while ($this->current_position !== $_position) { |
|
220 | + while ($this->current_position !== $_position) |
|
221 | + { |
|
193 | 222 | $this->get_raw_record(); |
194 | 223 | } |
195 | 224 | break; |
@@ -202,12 +231,16 @@ discard block |
||
202 | 231 | * |
203 | 232 | * @return int |
204 | 233 | */ |
205 | - public function get_num_of_records( ) { |
|
206 | - if ($this->num_of_records > 0) { |
|
234 | + public function get_num_of_records( ) |
|
235 | + { |
|
236 | + if ($this->num_of_records > 0) |
|
237 | + { |
|
207 | 238 | return $this->num_of_records; |
208 | 239 | } |
209 | 240 | $current_position = $this->current_position; |
210 | - while ($this->get_raw_record()) {} |
|
241 | + while ($this->get_raw_record()) |
|
242 | + { |
|
243 | +} |
|
211 | 244 | $this->num_of_records = $this->current_position; |
212 | 245 | $this->get_record($current_position); |
213 | 246 | return $this->num_of_records; |
@@ -218,7 +251,8 @@ discard block |
||
218 | 251 | * |
219 | 252 | * @return int |
220 | 253 | */ |
221 | - public function get_current_position( ) { |
|
254 | + public function get_current_position( ) |
|
255 | + { |
|
222 | 256 | |
223 | 257 | return $this->current_position; |
224 | 258 | |
@@ -230,12 +264,16 @@ discard block |
||
230 | 264 | * |
231 | 265 | * @return |
232 | 266 | */ |
233 | - protected function do_fieldmapping( ) { |
|
267 | + protected function do_fieldmapping( ) |
|
268 | + { |
|
234 | 269 | $record = $this->record; |
235 | 270 | $this->record = array(); |
236 | 271 | foreach ($this->mapping as $cvs_idx => $new_idx) |
237 | 272 | { |
238 | - if( $new_idx == '' ) continue; |
|
273 | + if( $new_idx == '' ) |
|
274 | + { |
|
275 | + continue; |
|
276 | + } |
|
239 | 277 | $this->record[$new_idx] = $record[$cvs_idx]; |
240 | 278 | } |
241 | 279 | return true; |
@@ -246,8 +284,10 @@ discard block |
||
246 | 284 | * |
247 | 285 | * @return bool |
248 | 286 | */ |
249 | - protected function do_conversions() { |
|
250 | - if ( $record = importexport_helper_functions::conversion( $this->record, $this->conversion, $this->conversion_class )) { |
|
287 | + protected function do_conversions() |
|
288 | + { |
|
289 | + if ( $record = importexport_helper_functions::conversion( $this->record, $this->conversion, $this->conversion_class )) |
|
290 | + { |
|
251 | 291 | $this->record = $record; |
252 | 292 | return; |
253 | 293 | } |
@@ -264,16 +304,19 @@ discard block |
||
264 | 304 | * |
265 | 305 | * @return string warnings, if any |
266 | 306 | */ |
267 | - public static function convert(Array &$record, Array $fields = array(), $appname = null, Array $selects = array(), $format=0) { |
|
307 | + public static function convert(Array &$record, Array $fields = array(), $appname = null, Array $selects = array(), $format=0) |
|
308 | + { |
|
268 | 309 | $warnings = array(); |
269 | 310 | |
270 | 311 | // Automatic conversions |
271 | - if($appname) { |
|
312 | + if($appname) |
|
313 | + { |
|
272 | 314 | |
273 | 315 | // Load translations |
274 | 316 | Api\Translation::add_app($appname); |
275 | 317 | |
276 | - if(!self::$cf_parse_cache[$appname]) { |
|
318 | + if(!self::$cf_parse_cache[$appname]) |
|
319 | + { |
|
277 | 320 | $c_fields = importexport_export_csv::convert_parse_custom_fields($appname, $selects, $links, $methods); |
278 | 321 | self::$cf_parse_cache[$appname] = array($c_fields, $selects, $links, $methods); |
279 | 322 | } |
@@ -282,7 +325,10 @@ discard block |
||
282 | 325 | // Add in any fields that are keys to another app |
283 | 326 | foreach((array)$fields['links'] as $link_field => $app) |
284 | 327 | { |
285 | - if(is_numeric($link_field)) continue; |
|
328 | + if(is_numeric($link_field)) |
|
329 | + { |
|
330 | + continue; |
|
331 | + } |
|
286 | 332 | $links[$link_field] = $app; |
287 | 333 | // Set it as a normal link field |
288 | 334 | $fields['links'][] = $link_field; |
@@ -292,7 +338,8 @@ discard block |
||
292 | 338 | // Not quite a recursive merge, since only one level |
293 | 339 | foreach($fields as $type => &$list) |
294 | 340 | { |
295 | - if($c_fields[$type]) { |
|
341 | + if($c_fields[$type]) |
|
342 | + { |
|
296 | 343 | $list = array_merge($c_fields[$type], $list); |
297 | 344 | unset($c_fields[$type]); |
298 | 345 | } |
@@ -300,12 +347,15 @@ discard block |
||
300 | 347 | $fields += $c_fields; |
301 | 348 | $selects += $c_selects; |
302 | 349 | } |
303 | - if($fields) { |
|
304 | - foreach((array)$fields['select'] as $name) { |
|
350 | + if($fields) |
|
351 | + { |
|
352 | + foreach((array)$fields['select'] as $name) |
|
353 | + { |
|
305 | 354 | $record[$name] = static::find_select_key($record[$name], $selects[$name]); |
306 | 355 | } |
307 | 356 | |
308 | - foreach((array)$fields['links'] as $name) { |
|
357 | + foreach((array)$fields['links'] as $name) |
|
358 | + { |
|
309 | 359 | if($record[$name] && $links[$name]) |
310 | 360 | { |
311 | 361 | // Primary key to another app, not a link |
@@ -347,15 +397,19 @@ discard block |
||
347 | 397 | lang($links[$name]), $record[$name]). |
348 | 398 | ' - ' . lang('no matches'); |
349 | 399 | continue; |
350 | - } else { |
|
400 | + } |
|
401 | + else |
|
402 | + { |
|
351 | 403 | $record[$name] = key($results); |
352 | 404 | } |
353 | 405 | } |
354 | 406 | } |
355 | 407 | } |
356 | - foreach((array)$fields['select-account'] as $name) { |
|
408 | + foreach((array)$fields['select-account'] as $name) |
|
409 | + { |
|
357 | 410 | // Compare against null to deal with empty arrays |
358 | - if ($record[$name]) { |
|
411 | + if ($record[$name]) |
|
412 | + { |
|
359 | 413 | // Automatically handle text owner without explicit translation |
360 | 414 | $new_owner = importexport_helper_functions::account_name2id($record[$name]); |
361 | 415 | if(count($new_owner) != count(explode(',',$record[$name]))) |
@@ -363,20 +417,26 @@ discard block |
||
363 | 417 | // Unable to parse value into account |
364 | 418 | $warnings[] = $name . ': ' .lang('%1 is not a known user or group', $record[$name]); |
365 | 419 | } |
366 | - if($new_owner != '') { |
|
420 | + if($new_owner != '') |
|
421 | + { |
|
367 | 422 | $record[$name] = $new_owner; |
368 | - } else { |
|
423 | + } |
|
424 | + else |
|
425 | + { |
|
369 | 426 | // Clear it to prevent trouble later on |
370 | 427 | $record[$name] = ''; |
371 | 428 | } |
372 | 429 | } |
373 | 430 | } |
374 | - foreach((array)$fields['select-bool'] as $name) { |
|
375 | - if($record[$name] != null && $record[$name] != '') { |
|
431 | + foreach((array)$fields['select-bool'] as $name) |
|
432 | + { |
|
433 | + if($record[$name] != null && $record[$name] != '') |
|
434 | + { |
|
376 | 435 | $record[$name] = (strtolower($record[$name]) == strtolower(lang('Yes')) || $record[$name] == '1' ? 1 : 0); |
377 | 436 | } |
378 | 437 | } |
379 | - foreach((array)$fields['date-time'] as $name) { |
|
438 | + foreach((array)$fields['date-time'] as $name) |
|
439 | + { |
|
380 | 440 | if (isset($record[$name]) && !is_numeric($record[$name]) && strlen(trim($record[$name])) > 0) |
381 | 441 | { |
382 | 442 | // Need to handle format first |
@@ -402,7 +462,8 @@ discard block |
||
402 | 462 | // Try again, anything goes |
403 | 463 | try { |
404 | 464 | $formatted = new Api\DateTime($record[$name]); |
405 | - } catch (Exception $e) { |
|
465 | + } |
|
466 | + catch (Exception $e) { |
|
406 | 467 | $warnings[] = $name.': ' . $e->getMessage() . "\n" . |
407 | 468 | 'Format: '.'!'.Api\DateTime::$user_dateformat . ' ' .Api\DateTime::$user_timeformat; |
408 | 469 | continue; |
@@ -424,7 +485,8 @@ discard block |
||
424 | 485 | } |
425 | 486 | |
426 | 487 | if(is_array(self::$cf_parse_cache[$appname][0]['date-time']) && |
427 | - in_array($name, self::$cf_parse_cache[$appname][0]['date-time'])) { |
|
488 | + in_array($name, self::$cf_parse_cache[$appname][0]['date-time'])) |
|
489 | + { |
|
428 | 490 | // Custom fields stored in a particular format (from customfields_widget) |
429 | 491 | $record[$name] = date('Y-m-d H:i:s', $record[$name]); |
430 | 492 | } |
@@ -434,7 +496,8 @@ discard block |
||
434 | 496 | $record[$name] = null; |
435 | 497 | } |
436 | 498 | } |
437 | - foreach((array)$fields['date'] as $name) { |
|
499 | + foreach((array)$fields['date'] as $name) |
|
500 | + { |
|
438 | 501 | if (isset($record[$name]) && !is_numeric($record[$name]) && strlen(trim($record[$name])) > 0) |
439 | 502 | { |
440 | 503 | // Need to handle format first |
@@ -448,7 +511,8 @@ discard block |
||
448 | 511 | } |
449 | 512 | $record[$name] = Api\DateTime::server2user($record[$name],'ts'); |
450 | 513 | if(is_array(self::$cf_parse_cache[$appname][0]['date']) && |
451 | - in_array($name, self::$cf_parse_cache[$appname][0]['date'])) { |
|
514 | + in_array($name, self::$cf_parse_cache[$appname][0]['date'])) |
|
515 | + { |
|
452 | 516 | // Custom fields stored in a particular format (from customfields_widget) |
453 | 517 | $record[$name] = date('Y-m-d', $record[$name]); |
454 | 518 | } |
@@ -460,26 +524,37 @@ discard block |
||
460 | 524 | } |
461 | 525 | foreach((array)$fields['float'] as $name) |
462 | 526 | { |
463 | - if($record[$name] != null && $record[$name] != '') { |
|
527 | + if($record[$name] != null && $record[$name] != '') |
|
528 | + { |
|
464 | 529 | $dec_point = $GLOBALS['egw_info']['user']['preferences']['common']['number_format'][0]; |
465 | - if (empty($dec_point)) $dec_point = '.'; |
|
530 | + if (empty($dec_point)) |
|
531 | + { |
|
532 | + $dec_point = '.'; |
|
533 | + } |
|
466 | 534 | $record[$name] = floatval(str_replace($dec_point, '.', preg_replace('/[^\d'.preg_quote($dec_point).']/', '', $record[$name]))); |
467 | 535 | } |
468 | 536 | } |
469 | 537 | |
470 | 538 | // Some custom methods for conversion |
471 | - foreach((array)$methods as $name => $method) { |
|
472 | - if($record[$name]) $record[$name] = ExecMethod($method, $record[$name]); |
|
539 | + foreach((array)$methods as $name => $method) |
|
540 | + { |
|
541 | + if($record[$name]) |
|
542 | + { |
|
543 | + $record[$name] = ExecMethod($method, $record[$name]); |
|
544 | + } |
|
473 | 545 | } |
474 | 546 | |
475 | 547 | // cat_name2id will use currentapp to create new categories |
476 | 548 | $current_app = $GLOBALS['egw_info']['flags']['currentapp']; |
477 | - if($appname) { |
|
549 | + if($appname) |
|
550 | + { |
|
478 | 551 | $GLOBALS['egw_info']['flags']['currentapp'] = $appname; |
479 | 552 | } |
480 | 553 | $categories = new Api\Categories('',$appname); |
481 | - foreach((array)$fields['select-cat'] as $name) { |
|
482 | - if($record[$name]) { |
|
554 | + foreach((array)$fields['select-cat'] as $name) |
|
555 | + { |
|
556 | + if($record[$name]) |
|
557 | + { |
|
483 | 558 | // Only parse name if it needs it |
484 | 559 | if($format == 1) |
485 | 560 | { |
@@ -493,7 +568,10 @@ discard block |
||
493 | 568 | $cat_id = importexport_helper_functions::cat_name2id($record[$name]); |
494 | 569 | } |
495 | 570 | // Don't clear it if it wasn't found |
496 | - if($cat_id) $record[$name] = $cat_id; |
|
571 | + if($cat_id) |
|
572 | + { |
|
573 | + $record[$name] = $cat_id; |
|
574 | + } |
|
497 | 575 | } |
498 | 576 | } |
499 | 577 | } |
@@ -514,7 +592,8 @@ discard block |
||
514 | 592 | */ |
515 | 593 | protected static function find_select_key($record_value, $selects) |
516 | 594 | { |
517 | - if($record_value != null && is_array($selects)) { |
|
595 | + if($record_value != null && is_array($selects)) |
|
596 | + { |
|
518 | 597 | if(is_array($record_value) || is_string($record_value) && strpos($record_value, ',') !== FALSE) |
519 | 598 | { |
520 | 599 | // Array, or CSV |
@@ -526,7 +605,10 @@ discard block |
||
526 | 605 | if(!$sub_key) |
527 | 606 | { |
528 | 607 | $sub_key = static::find_select_key(trim($subs[$sub_index]).','.trim($subs[$sub_index+1]), $selects); |
529 | - if($sub_key) $sub_index++; |
|
608 | + if($sub_key) |
|
609 | + { |
|
610 | + $sub_index++; |
|
611 | + } |
|
530 | 612 | } |
531 | 613 | if($sub_key) |
532 | 614 | { |
@@ -543,7 +625,10 @@ discard block |
||
543 | 625 | else |
544 | 626 | { |
545 | 627 | $key = array_search(strtolower($record_value), array_map('strtolower',array_map('lang',$selects))); |
546 | - if($key !== false) $record_value = $key; |
|
628 | + if($key !== false) |
|
629 | + { |
|
630 | + $record_value = $key; |
|
631 | + } |
|
547 | 632 | } |
548 | 633 | } |
549 | 634 |
@@ -295,7 +295,7 @@ |
||
295 | 295 | * |
296 | 296 | * @param importexport_iface_import_plugin $plugin Instance of plugin to be used |
297 | 297 | * @param resource $stream |
298 | - * @param importexport_definition $definition |
|
298 | + * @param importexport_definition $definition_obj |
|
299 | 299 | * @return String HTML fragment illustrating how the data will be understood by Egw |
300 | 300 | */ |
301 | 301 | protected function preview(importexport_iface_import_plugin &$plugin, &$stream, importexport_definition &$definition_obj) |
@@ -226,7 +226,7 @@ |
||
226 | 226 | /** |
227 | 227 | * Get options for select boxes |
228 | 228 | */ |
229 | - public static function get_select_options(Array $data) { |
|
229 | + public static function get_select_options(array $data) { |
|
230 | 230 | $options = array( |
231 | 231 | 'delimiter' => array( |
232 | 232 | '' => lang('From definition'), |
@@ -40,8 +40,8 @@ discard block |
||
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
43 | - * Step user through importing their file |
|
44 | - */ |
|
43 | + * Step user through importing their file |
|
44 | + */ |
|
45 | 45 | public function import_dialog($content = array()) { |
46 | 46 | $appname = $_GET['appname'] ? $_GET['appname'] : $content['appname']; |
47 | 47 | $definition = $_GET['definition'] ? $_GET['definition'] : $content['definition']; |
@@ -223,8 +223,8 @@ discard block |
||
223 | 223 | } |
224 | 224 | |
225 | 225 | /** |
226 | - * Get options for select boxes |
|
227 | - */ |
|
226 | + * Get options for select boxes |
|
227 | + */ |
|
228 | 228 | public static function get_select_options(Array $data) { |
229 | 229 | $options = array( |
230 | 230 | 'delimiter' => array( |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | private $plugins; |
37 | 37 | |
38 | 38 | public function __construct() { |
39 | - $this->plugins = importexport_helper_functions::get_plugins('all','import'); |
|
39 | + $this->plugins = importexport_helper_functions::get_plugins('all', 'import'); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -52,29 +52,29 @@ discard block |
||
52 | 52 | $template = new Etemplate('importexport.import_dialog'); |
53 | 53 | $preserve = array(); |
54 | 54 | |
55 | - if($definition) |
|
55 | + if ($definition) |
|
56 | 56 | { |
57 | 57 | $definition_obj = new importexport_definition($content['definition']); |
58 | 58 | } |
59 | 59 | |
60 | 60 | // Load application's translations |
61 | - if($appname) |
|
61 | + if ($appname) |
|
62 | 62 | { |
63 | 63 | Api\Translation::add_app($appname); |
64 | 64 | } |
65 | - if($content['import'] && $definition) { |
|
65 | + if ($content['import'] && $definition) { |
|
66 | 66 | try { |
67 | - if($content['dry-run']) { |
|
67 | + if ($content['dry-run']) { |
|
68 | 68 | // Set this so plugin doesn't do any data changes |
69 | 69 | $definition_obj->plugin_options = (array)$definition_obj->plugin_options + array('dry_run' => true); |
70 | 70 | } |
71 | - $options =& $definition_obj->plugin_options; |
|
71 | + $options = & $definition_obj->plugin_options; |
|
72 | 72 | $options['no_notification'] = $content['no_notifications']; |
73 | - if($content['delimiter']) { |
|
73 | + if ($content['delimiter']) { |
|
74 | 74 | $options['fieldsep'] = |
75 | 75 | $content['delimiter'] == 'other' ? $content['other_delimiter'] : $content['delimiter']; |
76 | 76 | } |
77 | - $options = array_merge($options, array_diff_key($content, array_flip(array('dry-run','file','import')))); |
|
77 | + $options = array_merge($options, array_diff_key($content, array_flip(array('dry-run', 'file', 'import')))); |
|
78 | 78 | $definition_obj->plugin_options = $options; |
79 | 79 | |
80 | 80 | $plugin = new $definition_obj->plugin; |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | // Check file encoding matches import |
83 | 83 | $sample = mb_substr(file_get_contents($content['file']['tmp_name'], false, null, 0, 2048), 1024); |
84 | 84 | |
85 | - if($appname == 'addressbook' && $definition_obj->plugin == 'addressbook_import_vcard') |
|
85 | + if ($appname == 'addressbook' && $definition_obj->plugin == 'addressbook_import_vcard') |
|
86 | 86 | { |
87 | 87 | $preference = $GLOBALS['egw_info']['user']['preferences']['addressbook']['vcard_charset']; |
88 | 88 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | } |
93 | 93 | $required = $options['charset'] == 'user' || !$options['charset'] ? $preference : $options['charset']; |
94 | 94 | $encoding = Api\Translation::detect_encoding($sample, $required); |
95 | - if($encoding && strtoupper($required) != strtoupper($encoding)) |
|
95 | + if ($encoding && strtoupper($required) != strtoupper($encoding)) |
|
96 | 96 | { |
97 | 97 | $this->message = lang("Encoding mismatch. Expected %1 file, you uploaded %2.<br />\n", |
98 | 98 | $required, |
@@ -107,37 +107,37 @@ discard block |
||
107 | 107 | $GLOBALS['egw_info']['flags']['currentapp'] = $appname; |
108 | 108 | |
109 | 109 | // Destination if we need to hold the file |
110 | - if($file) |
|
110 | + if ($file) |
|
111 | 111 | { |
112 | 112 | $cachefile = new Api\Cache\Files(array()); |
113 | 113 | $dst_file = $cachefile->filename(Api\Cache::keys(Api\Cache::INSTANCE, 'importexport', |
114 | - 'import_'.md5($content['file']['name'].$GLOBALS['egw_info']['user']['account_id']), true),true); |
|
114 | + 'import_'.md5($content['file']['name'].$GLOBALS['egw_info']['user']['account_id']), true), true); |
|
115 | 115 | // Keep file |
116 | - if($dst_file) |
|
116 | + if ($dst_file) |
|
117 | 117 | { |
118 | - if($content['file']['name'] && copy($content['file']['tmp_name'],$dst_file)) { |
|
118 | + if ($content['file']['name'] && copy($content['file']['tmp_name'], $dst_file)) { |
|
119 | 119 | $preserve['file']['tmp_name'] = $dst_file; |
120 | 120 | } |
121 | 121 | } |
122 | 122 | |
123 | 123 | // Check on matching columns |
124 | 124 | $check_message = array(); |
125 | - if(!self::check_file($file, $definition_obj, $check_message, $dst_file)) |
|
125 | + if (!self::check_file($file, $definition_obj, $check_message, $dst_file)) |
|
126 | 126 | { |
127 | 127 | // Set this so plugin doesn't do any data changes |
128 | 128 | $content['dry-run'] = true; |
129 | 129 | importexport_helper_functions::$dry_run = true; |
130 | - $this->message .= '<b>' . lang('Import aborted').":</b><br />\n"; |
|
130 | + $this->message .= '<b>'.lang('Import aborted').":</b><br />\n"; |
|
131 | 131 | $definition_obj->plugin_options = (array)$definition_obj->plugin_options + array('dry_run' => true); |
132 | 132 | } |
133 | - if(count($check_message)) |
|
133 | + if (count($check_message)) |
|
134 | 134 | { |
135 | - $this->message .= implode($check_message, "<br />\n") . "<br />\n"; |
|
135 | + $this->message .= implode($check_message, "<br />\n")."<br />\n"; |
|
136 | 136 | } |
137 | - if($content['dry-run']) |
|
137 | + if ($content['dry-run']) |
|
138 | 138 | { |
139 | 139 | $preview = $this->preview($plugin, $file, $definition_obj); |
140 | - if(trim($this->message) == '') |
|
140 | + if (trim($this->message) == '') |
|
141 | 141 | { |
142 | 142 | // Clear first, to prevent request from being collected if the result is the same |
143 | 143 | $template->setElementAttribute('preview', 'value', ''); |
@@ -156,34 +156,34 @@ discard block |
||
156 | 156 | $this->message .= lang('please select file to import'."<br />\n"); |
157 | 157 | } |
158 | 158 | |
159 | - if($content['dry-run']) |
|
159 | + if ($content['dry-run']) |
|
160 | 160 | { |
161 | - $this->message .= '<b>' . lang('test only').":</b><br />\n"; |
|
161 | + $this->message .= '<b>'.lang('test only').":</b><br />\n"; |
|
162 | 162 | } |
163 | 163 | $this->message .= lang('%1 records processed', $count); |
164 | 164 | |
165 | 165 | // Refresh opening window |
166 | - if(!$content['dry-run']) |
|
166 | + if (!$content['dry-run']) |
|
167 | 167 | { |
168 | - Framework::refresh_opener(lang('%1 records processed',$count), $appname, null,null,$appname); |
|
168 | + Framework::refresh_opener(lang('%1 records processed', $count), $appname, null, null, $appname); |
|
169 | 169 | } |
170 | 170 | $total_processed = 0; |
171 | - foreach($plugin->get_results() as $action => $a_count) { |
|
172 | - $this->message .= "<br />\n" . lang($action) . ": $a_count"; |
|
171 | + foreach ($plugin->get_results() as $action => $a_count) { |
|
172 | + $this->message .= "<br />\n".lang($action).": $a_count"; |
|
173 | 173 | $total_processed += $a_count; |
174 | 174 | } |
175 | - if(count($plugin->get_warnings())) { |
|
175 | + if (count($plugin->get_warnings())) { |
|
176 | 176 | $this->message .= "<br />\n".lang('Warnings').':'; |
177 | - foreach($plugin->get_warnings() as $record => $message) { |
|
177 | + foreach ($plugin->get_warnings() as $record => $message) { |
|
178 | 178 | $this->message .= "<br />\n$record: $message"; |
179 | 179 | } |
180 | 180 | } |
181 | - if(count($plugin->get_errors())) { |
|
181 | + if (count($plugin->get_errors())) { |
|
182 | 182 | $this->message .= "<br />\n".lang('Problems during import:'); |
183 | - foreach($plugin->get_errors() as $record => $message) { |
|
183 | + foreach ($plugin->get_errors() as $record => $message) { |
|
184 | 184 | $this->message .= "<br />\n$record: $message"; |
185 | 185 | } |
186 | - if($count != $total_processed) $this->message .= "<br />\n".lang('Some records may not have been imported'); |
|
186 | + if ($count != $total_processed) $this->message .= "<br />\n".lang('Some records may not have been imported'); |
|
187 | 187 | } |
188 | 188 | if ($dst_file && $content['file']['tmp_name'] == $dst_file) { |
189 | 189 | // Remove file |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | $this->message .= $e->getMessage(); |
199 | 199 | } |
200 | 200 | } |
201 | - elseif($content['cancel']) |
|
201 | + elseif ($content['cancel']) |
|
202 | 202 | { |
203 | 203 | egw_framework::set_onload('window.close();'); |
204 | 204 | } |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | ); |
212 | 212 | } |
213 | 213 | |
214 | - if(!array_key_exists('dry-run',$content)) |
|
214 | + if (!array_key_exists('dry-run', $content)) |
|
215 | 215 | { |
216 | 216 | $data['dry-run'] = true; |
217 | 217 | } |
@@ -219,20 +219,20 @@ discard block |
||
219 | 219 | $data['appname'] = $preserve['appname'] = $appname ? $appname : ($definition_obj ? $definition_obj->application : ''); |
220 | 220 | $data['definition'] = $definition; |
221 | 221 | $data['delimiter'] = $definition_obj->plugin_options['delimiter']; |
222 | - $data['no_notifications'] = true; // switch notifications off by default |
|
222 | + $data['no_notifications'] = true; // switch notifications off by default |
|
223 | 223 | |
224 | 224 | $sel_options = self::get_select_options($data); |
225 | 225 | $readonlys = array(); |
226 | 226 | |
227 | - if(!$definition_obj && $sel_options['definition'] && !$data['definition']) |
|
227 | + if (!$definition_obj && $sel_options['definition'] && !$data['definition']) |
|
228 | 228 | { |
229 | 229 | $definition_obj = new importexport_definition(key($sel_options['definition'])); |
230 | 230 | } |
231 | - if($definition_obj) |
|
231 | + if ($definition_obj) |
|
232 | 232 | { |
233 | 233 | $plugin = new $definition_obj->plugin; |
234 | 234 | $options = $plugin->get_options_etpl($definition_obj); |
235 | - if(is_array($options)) |
|
235 | + if (is_array($options)) |
|
236 | 236 | { |
237 | 237 | $data['plugin_options_template'] = $options['name']; |
238 | 238 | $data += (array)$options['content']; |
@@ -249,9 +249,9 @@ discard block |
||
249 | 249 | } |
250 | 250 | |
251 | 251 | $data['message'] = $this->message; |
252 | - Framework::includeJS('.','importexport','importexport'); |
|
252 | + Framework::includeJS('.', 'importexport', 'importexport'); |
|
253 | 253 | |
254 | - if($_GET['appname']) $readonlys['appname'] = true; |
|
254 | + if ($_GET['appname']) $readonlys['appname'] = true; |
|
255 | 255 | |
256 | 256 | $template->exec('importexport.importexport_import_ui.import_dialog', $data, $sel_options, $readonlys, $preserve, 2); |
257 | 257 | } |
@@ -273,12 +273,12 @@ discard block |
||
273 | 273 | ); |
274 | 274 | |
275 | 275 | (array)$apps = importexport_helper_functions::get_apps('import'); |
276 | - $options['appname'] = array('' => lang('Select one')) + array_combine($apps,$apps); |
|
276 | + $options['appname'] = array('' => lang('Select one')) + array_combine($apps, $apps); |
|
277 | 277 | |
278 | - if($data['appname']) { |
|
278 | + if ($data['appname']) { |
|
279 | 279 | $options['definition'] = array(); |
280 | 280 | |
281 | - if($data['file'] && !is_array($data['file'])) { |
|
281 | + if ($data['file'] && !is_array($data['file'])) { |
|
282 | 282 | $extension = substr($data['file'], -3); |
283 | 283 | } |
284 | 284 | $definitions = new importexport_definitions_bo(array( |
@@ -318,26 +318,26 @@ discard block |
||
318 | 318 | */ |
319 | 319 | protected function preview(importexport_iface_import_plugin &$plugin, &$stream, importexport_definition &$definition_obj) |
320 | 320 | { |
321 | - if(method_exists($plugin, 'preview')) |
|
321 | + if (method_exists($plugin, 'preview')) |
|
322 | 322 | { |
323 | 323 | $preview = $plugin->preview($stream, $definition_obj); |
324 | 324 | } |
325 | - elseif($definition_obj->plugin_options['csv_fields']) |
|
325 | + elseif ($definition_obj->plugin_options['csv_fields']) |
|
326 | 326 | { |
327 | - $import_csv = new importexport_import_csv( $stream, array( |
|
327 | + $import_csv = new importexport_import_csv($stream, array( |
|
328 | 328 | 'fieldsep' => $definition_obj->plugin_options['fieldsep'], |
329 | 329 | 'charset' => $definition_obj->plugin_options['charset'], |
330 | 330 | )); |
331 | 331 | // set FieldMapping. |
332 | 332 | $import_csv->mapping = $definition_obj->plugin_options['field_mapping']; |
333 | 333 | |
334 | - $rows = array('h1'=>array(),'f1'=>array(),'.h1'=>'class=th'); |
|
335 | - for($row = 0; $row < $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']; $row++) |
|
334 | + $rows = array('h1'=>array(), 'f1'=>array(), '.h1'=>'class=th'); |
|
335 | + for ($row = 0; $row < $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']; $row++) |
|
336 | 336 | { |
337 | 337 | $row_data = $import_csv->get_record(); |
338 | - if($row_data === false) break; |
|
338 | + if ($row_data === false) break; |
|
339 | 339 | $rows[$import_csv->get_current_position() <= $definition_obj->plugin_options['num_header_lines'] ? 'h1' : $row] = $row_data; |
340 | - if($import_csv->get_current_position() <= $definition_obj->plugin_options['num_header_lines']) $row--; |
|
340 | + if ($import_csv->get_current_position() <= $definition_obj->plugin_options['num_header_lines']) $row--; |
|
341 | 341 | } |
342 | 342 | $preview = Api\Html::table($rows); |
343 | 343 | rewind($stream); |
@@ -346,22 +346,22 @@ discard block |
||
346 | 346 | { |
347 | 347 | $preview = lang('Preview not supported by %1', $plugin->get_name()); |
348 | 348 | } |
349 | - if(count($plugin->get_warnings())) { |
|
349 | + if (count($plugin->get_warnings())) { |
|
350 | 350 | $this->message .= "<br />\n".lang('Warnings').':'; |
351 | - foreach($plugin->get_warnings() as $record => $message) { |
|
351 | + foreach ($plugin->get_warnings() as $record => $message) { |
|
352 | 352 | $this->message .= "\n$record: $message"; |
353 | 353 | } |
354 | 354 | $this->message .= "<br />\n"; |
355 | 355 | }; |
356 | - if(count($plugin->get_errors())) { |
|
356 | + if (count($plugin->get_errors())) { |
|
357 | 357 | $this->message .= "<br />\n".lang('Problems during import:'); |
358 | - foreach($plugin->get_errors() as $record => $message) { |
|
358 | + foreach ($plugin->get_errors() as $record => $message) { |
|
359 | 359 | $this->message .= "<br />\n$record: $message"; |
360 | 360 | } |
361 | - if($count != $total_processed) $this->message .= "<br />\n".lang('Some records may not have been imported'); |
|
361 | + if ($count != $total_processed) $this->message .= "<br />\n".lang('Some records may not have been imported'); |
|
362 | 362 | $this->message .= "<br />\n"; |
363 | 363 | } |
364 | - return '<div class="header">' . lang('Preview') . ' - ' . $plugin->get_name() . '</div>' . $preview; |
|
364 | + return '<div class="header">'.lang('Preview').' - '.$plugin->get_name().'</div>'.$preview; |
|
365 | 365 | } |
366 | 366 | |
367 | 367 | /** |
@@ -379,24 +379,24 @@ discard block |
||
379 | 379 | */ |
380 | 380 | public static function check_file(&$file, &$definition, &$message = array(), $dst_file = false) |
381 | 381 | { |
382 | - $options =& $definition->plugin_options; |
|
382 | + $options = & $definition->plugin_options; |
|
383 | 383 | $message_count = count($message); |
384 | 384 | |
385 | 385 | // Only CSV files |
386 | - if(!$options['csv_fields']) return true; |
|
386 | + if (!$options['csv_fields']) return true; |
|
387 | 387 | |
388 | 388 | // Can't check if definition has no header |
389 | - if($options['num_header_lines'] == 0) return true; |
|
389 | + if ($options['num_header_lines'] == 0) return true; |
|
390 | 390 | |
391 | 391 | $preference = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset']; |
392 | 392 | $charset = $options['charset'] == 'user' || !$options['charset'] ? $preference : $options['charset']; |
393 | 393 | |
394 | 394 | $data = fgetcsv($file, 8000, $options['fieldsep']); |
395 | 395 | rewind($file); |
396 | - $data = Api\Translation::convert($data,$charset); |
|
396 | + $data = Api\Translation::convert($data, $charset); |
|
397 | 397 | |
398 | 398 | $ok = true; |
399 | - if(count($data) != count($options['csv_fields']) && max(array_keys($data)) != max(array_keys($options['csv_fields']))) |
|
399 | + if (count($data) != count($options['csv_fields']) && max(array_keys($data)) != max(array_keys($options['csv_fields']))) |
|
400 | 400 | { |
401 | 401 | $message[] = lang("Column mismatch. Expected %1 columns, your file has %2.", |
402 | 402 | count($options['field_mapping']), |
@@ -404,9 +404,9 @@ discard block |
||
404 | 404 | ); |
405 | 405 | $ok = false; |
406 | 406 | } |
407 | - foreach($data as $index => $header) |
|
407 | + foreach ($data as $index => $header) |
|
408 | 408 | { |
409 | - if($index < count($options['csv_fields']) && !$options['field_mapping'][$index]) |
|
409 | + if ($index < count($options['csv_fields']) && !$options['field_mapping'][$index]) |
|
410 | 410 | { |
411 | 411 | // Skipped column in definition |
412 | 412 | continue; |
@@ -418,16 +418,16 @@ discard block |
||
418 | 418 | } |
419 | 419 | |
420 | 420 | // Check for matching headers |
421 | - if($options['csv_fields'][$index] == $header) |
|
421 | + if ($options['csv_fields'][$index] == $header) |
|
422 | 422 | { |
423 | 423 | // Simple match |
424 | 424 | continue; |
425 | 425 | } |
426 | 426 | // Check column headers, taking into account different translations - make sure no * |
427 | - $lang_defn = mb_strtoupper(Api\Translation::translate($options['csv_fields'][$index],false,'')); |
|
428 | - $lang_file = mb_strtoupper(Api\Translation::translate($header,false,'')); |
|
427 | + $lang_defn = mb_strtoupper(Api\Translation::translate($options['csv_fields'][$index], false, '')); |
|
428 | + $lang_file = mb_strtoupper(Api\Translation::translate($header, false, '')); |
|
429 | 429 | |
430 | - if($lang_defn == $lang_file || |
|
430 | + if ($lang_defn == $lang_file || |
|
431 | 431 | $lang_defn == mb_strtoupper($header) || |
432 | 432 | $lang_file == mb_strtoupper($options['csv_fields'][$index]) |
433 | 433 | ) |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | $file_message_id = Api\Translation::get_message_id($header, $definition->application); |
440 | 440 | $defn_message_id = Api\Translation::get_message_id($options['csv_fields'][$index], $definition->application); |
441 | 441 | |
442 | - if($file_message_id && $defn_message_id && $file_message_id == $defn_message_id) |
|
442 | + if ($file_message_id && $defn_message_id && $file_message_id == $defn_message_id) |
|
443 | 443 | { |
444 | 444 | continue; |
445 | 445 | } |
@@ -447,19 +447,19 @@ discard block |
||
447 | 447 | |
448 | 448 | // Problem |
449 | 449 | $message[] = lang("Column mismatch: %1 should be %2, not %3", |
450 | - $index,$options['csv_fields'][$index], $header); |
|
450 | + $index, $options['csv_fields'][$index], $header); |
|
451 | 451 | // But can still continue |
452 | 452 | // $ok = false; |
453 | 453 | } |
454 | - if(!$ok || count($message) != $message_count) |
|
454 | + if (!$ok || count($message) != $message_count) |
|
455 | 455 | { |
456 | 456 | // Add links for new / edit definition |
457 | 457 | $config = Api\Config::read('importexport'); |
458 | - if($GLOBALS['egw_info']['user']['apps']['admin'] || $config['users_create_definitions']) |
|
458 | + if ($GLOBALS['egw_info']['user']['apps']['admin'] || $config['users_create_definitions']) |
|
459 | 459 | { |
460 | 460 | $actions = []; |
461 | 461 | // New definition |
462 | - $add_link = Egw::link('/index.php',array( |
|
462 | + $add_link = Egw::link('/index.php', array( |
|
463 | 463 | 'menuaction' => 'importexport.importexport_definitions_ui.edit', |
464 | 464 | 'application' => $definition->application, |
465 | 465 | 'plugin' => $definition->plugin, |
@@ -471,13 +471,13 @@ discard block |
||
471 | 471 | 'menuaction' => 'importexport.importexport_import_ui.import_dialog', |
472 | 472 | // Don't set appname, or user won't be able to select & see their new definition |
473 | 473 | //'appname' => $definition->application, |
474 | - )) . "'; |
|
474 | + ))."'; |
|
475 | 475 | egw_openWindowCentered2('$add_link','_blank',500,500,'yes'); |
476 | 476 | "; |
477 | 477 | $actions[] = lang('Create a <a href="%1">new definition</a> for this file', $add_link); |
478 | 478 | |
479 | 479 | // Edit selected definition, if allowed |
480 | - if($definition->owner == $GLOBALS['egw_info']['user']['account_id'] || |
|
480 | + if ($definition->owner == $GLOBALS['egw_info']['user']['account_id'] || |
|
481 | 481 | !$definition->owner && $GLOBALS['egw_info']['user']['apps']['admin']) |
482 | 482 | { |
483 | 483 | $edit_link = array( |
@@ -486,20 +486,20 @@ discard block |
||
486 | 486 | // Jump to file step |
487 | 487 | 'step' => 'wizard_step21' |
488 | 488 | ); |
489 | - if($dst_file) |
|
489 | + if ($dst_file) |
|
490 | 490 | { |
491 | 491 | // Still have uploaded file, jump there |
492 | - Api\Cache::setSession($definition->application,'csvfile',$dst_file); |
|
492 | + Api\Cache::setSession($definition->application, 'csvfile', $dst_file); |
|
493 | 493 | $edit_link['step'] = 'wizard_step30'; |
494 | 494 | } |
495 | - $edit_link = Egw::link('/index.php',$edit_link); |
|
495 | + $edit_link = Egw::link('/index.php', $edit_link); |
|
496 | 496 | $edit_link = "javascript:egw_openWindowCentered2('$edit_link','_blank',500,500,'yes')"; |
497 | 497 | $actions[] = lang('Edit definition <a href="%1">%2</a> to match your file', |
498 | - $edit_link, $definition->name ); |
|
498 | + $edit_link, $definition->name); |
|
499 | 499 | } |
500 | - $actions[] = lang('Edit your file to match the definition:') . ' ' |
|
501 | - . implode(array_map('lang',array_intersect_key($options['csv_fields'],$options['field_mapping'])),', '); |
|
502 | - $message[] = "\n<li>".implode($actions,"\n<li>"); |
|
500 | + $actions[] = lang('Edit your file to match the definition:').' ' |
|
501 | + . implode(array_map('lang', array_intersect_key($options['csv_fields'], $options['field_mapping'])), ', '); |
|
502 | + $message[] = "\n<li>".implode($actions, "\n<li>"); |
|
503 | 503 | } |
504 | 504 | } |
505 | 505 | return $ok; |
@@ -20,7 +20,8 @@ discard block |
||
20 | 20 | * |
21 | 21 | */ |
22 | 22 | |
23 | - class importexport_import_ui { |
|
23 | + class importexport_import_ui |
|
24 | + { |
|
24 | 25 | |
25 | 26 | const _appname = 'importexport'; |
26 | 27 | |
@@ -35,14 +36,16 @@ discard block |
||
35 | 36 | */ |
36 | 37 | private $plugins; |
37 | 38 | |
38 | - public function __construct() { |
|
39 | + public function __construct() |
|
40 | + { |
|
39 | 41 | $this->plugins = importexport_helper_functions::get_plugins('all','import'); |
40 | 42 | } |
41 | 43 | |
42 | 44 | /** |
43 | 45 | * Step user through importing their file |
44 | 46 | */ |
45 | - public function import_dialog($content = array()) { |
|
47 | + public function import_dialog($content = array()) |
|
48 | + { |
|
46 | 49 | $appname = $_GET['appname'] ? $_GET['appname'] : $content['appname']; |
47 | 50 | $definition = $_GET['definition'] ? $_GET['definition'] : $content['definition']; |
48 | 51 | |
@@ -62,15 +65,18 @@ discard block |
||
62 | 65 | { |
63 | 66 | Api\Translation::add_app($appname); |
64 | 67 | } |
65 | - if($content['import'] && $definition) { |
|
68 | + if($content['import'] && $definition) |
|
69 | + { |
|
66 | 70 | try { |
67 | - if($content['dry-run']) { |
|
71 | + if($content['dry-run']) |
|
72 | + { |
|
68 | 73 | // Set this so plugin doesn't do any data changes |
69 | 74 | $definition_obj->plugin_options = (array)$definition_obj->plugin_options + array('dry_run' => true); |
70 | 75 | } |
71 | 76 | $options =& $definition_obj->plugin_options; |
72 | 77 | $options['no_notification'] = $content['no_notifications']; |
73 | - if($content['delimiter']) { |
|
78 | + if($content['delimiter']) |
|
79 | + { |
|
74 | 80 | $options['fieldsep'] = |
75 | 81 | $content['delimiter'] == 'other' ? $content['other_delimiter'] : $content['delimiter']; |
76 | 82 | } |
@@ -115,7 +121,8 @@ discard block |
||
115 | 121 | // Keep file |
116 | 122 | if($dst_file) |
117 | 123 | { |
118 | - if($content['file']['name'] && copy($content['file']['tmp_name'],$dst_file)) { |
|
124 | + if($content['file']['name'] && copy($content['file']['tmp_name'],$dst_file)) |
|
125 | + { |
|
119 | 126 | $preserve['file']['tmp_name'] = $dst_file; |
120 | 127 | } |
121 | 128 | } |
@@ -168,33 +175,44 @@ discard block |
||
168 | 175 | Framework::refresh_opener(lang('%1 records processed',$count), $appname, null,null,$appname); |
169 | 176 | } |
170 | 177 | $total_processed = 0; |
171 | - foreach($plugin->get_results() as $action => $a_count) { |
|
178 | + foreach($plugin->get_results() as $action => $a_count) |
|
179 | + { |
|
172 | 180 | $this->message .= "<br />\n" . lang($action) . ": $a_count"; |
173 | 181 | $total_processed += $a_count; |
174 | 182 | } |
175 | - if(count($plugin->get_warnings())) { |
|
183 | + if(count($plugin->get_warnings())) |
|
184 | + { |
|
176 | 185 | $this->message .= "<br />\n".lang('Warnings').':'; |
177 | - foreach($plugin->get_warnings() as $record => $message) { |
|
186 | + foreach($plugin->get_warnings() as $record => $message) |
|
187 | + { |
|
178 | 188 | $this->message .= "<br />\n$record: $message"; |
179 | 189 | } |
180 | 190 | } |
181 | - if(count($plugin->get_errors())) { |
|
191 | + if(count($plugin->get_errors())) |
|
192 | + { |
|
182 | 193 | $this->message .= "<br />\n".lang('Problems during import:'); |
183 | - foreach($plugin->get_errors() as $record => $message) { |
|
194 | + foreach($plugin->get_errors() as $record => $message) |
|
195 | + { |
|
184 | 196 | $this->message .= "<br />\n$record: $message"; |
185 | 197 | } |
186 | - if($count != $total_processed) $this->message .= "<br />\n".lang('Some records may not have been imported'); |
|
198 | + if($count != $total_processed) |
|
199 | + { |
|
200 | + $this->message .= "<br />\n".lang('Some records may not have been imported'); |
|
201 | + } |
|
187 | 202 | } |
188 | - if ($dst_file && $content['file']['tmp_name'] == $dst_file) { |
|
203 | + if ($dst_file && $content['file']['tmp_name'] == $dst_file) |
|
204 | + { |
|
189 | 205 | // Remove file |
190 | 206 | $cachefile->delete(Api\Cache::keys(Api\Cache::INSTANCE, 'importexport', |
191 | 207 | 'import_'.md5($content['file']['name'].$GLOBALS['egw_info']['user']['account_id']))); |
192 | 208 | unset($dst_file); |
193 | 209 | } |
194 | 210 | |
195 | - } catch (Api\Db\Exception $db_ex) { |
|
211 | + } |
|
212 | + catch (Api\Db\Exception $db_ex) { |
|
196 | 213 | $this->message .= lang('Database error'); |
197 | - } catch (Exception $e) { |
|
214 | + } |
|
215 | + catch (Exception $e) { |
|
198 | 216 | $this->message .= $e->getMessage(); |
199 | 217 | } |
200 | 218 | } |
@@ -251,7 +269,10 @@ discard block |
||
251 | 269 | $data['message'] = $this->message; |
252 | 270 | Framework::includeJS('.','importexport','importexport'); |
253 | 271 | |
254 | - if($_GET['appname']) $readonlys['appname'] = true; |
|
272 | + if($_GET['appname']) |
|
273 | + { |
|
274 | + $readonlys['appname'] = true; |
|
275 | + } |
|
255 | 276 | |
256 | 277 | $template->exec('importexport.importexport_import_ui.import_dialog', $data, $sel_options, $readonlys, $preserve, 2); |
257 | 278 | } |
@@ -259,7 +280,8 @@ discard block |
||
259 | 280 | /** |
260 | 281 | * Get options for select boxes |
261 | 282 | */ |
262 | - public static function get_select_options(Array $data) { |
|
283 | + public static function get_select_options(Array $data) |
|
284 | + { |
|
263 | 285 | $options = array( |
264 | 286 | 'delimiter' => array( |
265 | 287 | '' => lang('From definition'), |
@@ -275,17 +297,20 @@ discard block |
||
275 | 297 | (array)$apps = importexport_helper_functions::get_apps('import'); |
276 | 298 | $options['appname'] = array('' => lang('Select one')) + array_combine($apps,$apps); |
277 | 299 | |
278 | - if($data['appname']) { |
|
300 | + if($data['appname']) |
|
301 | + { |
|
279 | 302 | $options['definition'] = array(); |
280 | 303 | |
281 | - if($data['file'] && !is_array($data['file'])) { |
|
304 | + if($data['file'] && !is_array($data['file'])) |
|
305 | + { |
|
282 | 306 | $extension = substr($data['file'], -3); |
283 | 307 | } |
284 | 308 | $definitions = new importexport_definitions_bo(array( |
285 | 309 | 'type' => 'import', |
286 | 310 | 'application' => $data['appname'] |
287 | 311 | )); |
288 | - foreach ((array)$definitions->get_definitions() as $identifier) { |
|
312 | + foreach ((array)$definitions->get_definitions() as $identifier) |
|
313 | + { |
|
289 | 314 | try |
290 | 315 | { |
291 | 316 | $definition = new importexport_definition($identifier); |
@@ -295,7 +320,8 @@ discard block |
||
295 | 320 | // Permission error |
296 | 321 | continue; |
297 | 322 | } |
298 | - if ($title = $definition->get_title()) { |
|
323 | + if ($title = $definition->get_title()) |
|
324 | + { |
|
299 | 325 | $options['definition'][$title] = $title; |
300 | 326 | } |
301 | 327 | unset($definition); |
@@ -335,9 +361,15 @@ discard block |
||
335 | 361 | for($row = 0; $row < $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']; $row++) |
336 | 362 | { |
337 | 363 | $row_data = $import_csv->get_record(); |
338 | - if($row_data === false) break; |
|
364 | + if($row_data === false) |
|
365 | + { |
|
366 | + break; |
|
367 | + } |
|
339 | 368 | $rows[$import_csv->get_current_position() <= $definition_obj->plugin_options['num_header_lines'] ? 'h1' : $row] = $row_data; |
340 | - if($import_csv->get_current_position() <= $definition_obj->plugin_options['num_header_lines']) $row--; |
|
369 | + if($import_csv->get_current_position() <= $definition_obj->plugin_options['num_header_lines']) |
|
370 | + { |
|
371 | + $row--; |
|
372 | + } |
|
341 | 373 | } |
342 | 374 | $preview = Api\Html::table($rows); |
343 | 375 | rewind($stream); |
@@ -346,19 +378,26 @@ discard block |
||
346 | 378 | { |
347 | 379 | $preview = lang('Preview not supported by %1', $plugin->get_name()); |
348 | 380 | } |
349 | - if(count($plugin->get_warnings())) { |
|
381 | + if(count($plugin->get_warnings())) |
|
382 | + { |
|
350 | 383 | $this->message .= "<br />\n".lang('Warnings').':'; |
351 | - foreach($plugin->get_warnings() as $record => $message) { |
|
384 | + foreach($plugin->get_warnings() as $record => $message) |
|
385 | + { |
|
352 | 386 | $this->message .= "\n$record: $message"; |
353 | 387 | } |
354 | 388 | $this->message .= "<br />\n"; |
355 | 389 | }; |
356 | - if(count($plugin->get_errors())) { |
|
390 | + if(count($plugin->get_errors())) |
|
391 | + { |
|
357 | 392 | $this->message .= "<br />\n".lang('Problems during import:'); |
358 | - foreach($plugin->get_errors() as $record => $message) { |
|
393 | + foreach($plugin->get_errors() as $record => $message) |
|
394 | + { |
|
359 | 395 | $this->message .= "<br />\n$record: $message"; |
360 | 396 | } |
361 | - if($count != $total_processed) $this->message .= "<br />\n".lang('Some records may not have been imported'); |
|
397 | + if($count != $total_processed) |
|
398 | + { |
|
399 | + $this->message .= "<br />\n".lang('Some records may not have been imported'); |
|
400 | + } |
|
362 | 401 | $this->message .= "<br />\n"; |
363 | 402 | } |
364 | 403 | return '<div class="header">' . lang('Preview') . ' - ' . $plugin->get_name() . '</div>' . $preview; |
@@ -383,10 +422,16 @@ discard block |
||
383 | 422 | $message_count = count($message); |
384 | 423 | |
385 | 424 | // Only CSV files |
386 | - if(!$options['csv_fields']) return true; |
|
425 | + if(!$options['csv_fields']) |
|
426 | + { |
|
427 | + return true; |
|
428 | + } |
|
387 | 429 | |
388 | 430 | // Can't check if definition has no header |
389 | - if($options['num_header_lines'] == 0) return true; |
|
431 | + if($options['num_header_lines'] == 0) |
|
432 | + { |
|
433 | + return true; |
|
434 | + } |
|
390 | 435 | |
391 | 436 | $preference = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset']; |
392 | 437 | $charset = $options['charset'] == 'user' || !$options['charset'] ? $preference : $options['charset']; |
@@ -430,8 +475,7 @@ discard block |
||
430 | 475 | if($lang_defn == $lang_file || |
431 | 476 | $lang_defn == mb_strtoupper($header) || |
432 | 477 | $lang_file == mb_strtoupper($options['csv_fields'][$index]) |
433 | - ) |
|
434 | - { |
|
478 | + ) { |
|
435 | 479 | continue; |
436 | 480 | } |
437 | 481 |