@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * @param string|int|array $account account name or id, or array with all parameters |
24 | 24 | * @param string $password =null password |
25 | 25 | */ |
26 | - function __construct($account,$password=null) |
|
26 | + function __construct($account, $password = null) |
|
27 | 27 | { |
28 | 28 | if (!is_array($account)) |
29 | 29 | { |
@@ -44,11 +44,11 @@ discard block |
||
44 | 44 | * @throws Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!",$this->account),15); |
45 | 45 | * @throws Api\Exception\WrongUserinput(lang('Error changing the password for %1 !!!',$this->account),99); |
46 | 46 | */ |
47 | - protected function exec($check_only=false) |
|
47 | + protected function exec($check_only = false) |
|
48 | 48 | { |
49 | - $account_id = admin_cmd::parse_account($this->account,true); // true = user, no group |
|
49 | + $account_id = admin_cmd::parse_account($this->account, true); // true = user, no group |
|
50 | 50 | // check creator is still admin and not explicitly forbidden to edit Api\Accounts |
51 | - if ($this->creator) $this->_check_admin('account_access',16); |
|
51 | + if ($this->creator) $this->_check_admin('account_access', 16); |
|
52 | 52 | |
53 | 53 | if ($check_only) return true; |
54 | 54 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | if (!$auth->change_password(null, $this->password, $account_id)) |
58 | 58 | { |
59 | 59 | // as long as the Api\Auth class is not throwing itself ... |
60 | - throw new Exception(lang('Error changing the password for %1 !!!',$this->account),99); |
|
60 | + throw new Exception(lang('Error changing the password for %1 !!!', $this->account), 99); |
|
61 | 61 | } |
62 | 62 | return lang('Password updated'); |
63 | 63 | } |
@@ -69,6 +69,6 @@ discard block |
||
69 | 69 | */ |
70 | 70 | function __tostring() |
71 | 71 | { |
72 | - return lang('change password for %1',admin_cmd::display_account($this->account)); |
|
72 | + return lang('change password for %1', admin_cmd::display_account($this->account)); |
|
73 | 73 | } |
74 | 74 | } |
@@ -15,15 +15,15 @@ discard block |
||
15 | 15 | /** |
16 | 16 | * class import_csv for admin (users) |
17 | 17 | */ |
18 | -class admin_import_users_csv implements importexport_iface_import_plugin { |
|
18 | +class admin_import_users_csv implements importexport_iface_import_plugin { |
|
19 | 19 | |
20 | 20 | private static $plugin_options = array( |
21 | - 'fieldsep', // char |
|
22 | - 'charset', // string |
|
21 | + 'fieldsep', // char |
|
22 | + 'charset', // string |
|
23 | 23 | 'num_header_lines', // int number of header lines |
24 | 24 | 'field_conversion', // array( $csv_col_num => conversion) |
25 | - 'field_mapping', // array( $csv_col_num => adb_filed) |
|
26 | - 'conditions', /* => array containing condition arrays: |
|
25 | + 'field_mapping', // array( $csv_col_num => adb_filed) |
|
26 | + 'conditions', /* => array containing condition arrays: |
|
27 | 27 | 'type' => exists, // exists |
28 | 28 | 'string' => '#kundennummer', |
29 | 29 | 'true' => array( |
@@ -40,14 +40,14 @@ discard block |
||
40 | 40 | /** |
41 | 41 | * actions which could be done to data entries |
42 | 42 | */ |
43 | - protected static $actions = array( 'none', 'update', 'create', 'delete', 'disable', 'enable' ); |
|
43 | + protected static $actions = array('none', 'update', 'create', 'delete', 'disable', 'enable'); |
|
44 | 44 | |
45 | 45 | /** |
46 | 46 | * conditions for actions |
47 | 47 | * |
48 | 48 | * @var array |
49 | 49 | */ |
50 | - protected static $conditions = array( 'exists' ); |
|
50 | + protected static $conditions = array('exists'); |
|
51 | 51 | |
52 | 52 | /** |
53 | 53 | * @var definition |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | * @param string $_charset |
91 | 91 | * @param definition $_definition |
92 | 92 | */ |
93 | - public function import( $_stream, importexport_definition $_definition ) { |
|
94 | - $import_csv = new importexport_import_csv( $_stream, array( |
|
93 | + public function import($_stream, importexport_definition $_definition) { |
|
94 | + $import_csv = new importexport_import_csv($_stream, array( |
|
95 | 95 | 'fieldsep' => $_definition->plugin_options['fieldsep'], |
96 | 96 | 'charset' => $_definition->plugin_options['charset'], |
97 | 97 | )); |
@@ -99,11 +99,11 @@ discard block |
||
99 | 99 | $this->definition = $_definition; |
100 | 100 | |
101 | 101 | // user, is admin ? |
102 | - $this->is_admin = isset( $GLOBALS['egw_info']['user']['apps']['admin'] ) && $GLOBALS['egw_info']['user']['apps']['admin']; |
|
102 | + $this->is_admin = isset($GLOBALS['egw_info']['user']['apps']['admin']) && $GLOBALS['egw_info']['user']['apps']['admin']; |
|
103 | 103 | $this->user = $GLOBALS['egw_info']['user']['account_id']; |
104 | 104 | |
105 | 105 | // dry run? |
106 | - $this->dry_run = isset( $_definition->plugin_options['dry_run'] ) ? $_definition->plugin_options['dry_run'] : false; |
|
106 | + $this->dry_run = isset($_definition->plugin_options['dry_run']) ? $_definition->plugin_options['dry_run'] : false; |
|
107 | 107 | |
108 | 108 | // set FieldMapping. |
109 | 109 | $import_csv->mapping = $_definition->plugin_options['field_mapping']; |
@@ -112,9 +112,9 @@ discard block |
||
112 | 112 | $import_csv->conversion = $_definition->plugin_options['field_conversion']; |
113 | 113 | |
114 | 114 | //check if file has a header lines |
115 | - if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0) { |
|
115 | + if (isset($_definition->plugin_options['num_header_lines']) && $_definition->plugin_options['num_header_lines'] > 0) { |
|
116 | 116 | $import_csv->skip_records($_definition->plugin_options['num_header_lines']); |
117 | - } elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) { |
|
117 | + } elseif (isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) { |
|
118 | 118 | // First method is preferred |
119 | 119 | $import_csv->skip_records(1); |
120 | 120 | } |
@@ -130,22 +130,22 @@ discard block |
||
130 | 130 | 'account_status' => array('A' => lang('Active'), '' => lang('Disabled'), 'D' => lang('Disabled')), |
131 | 131 | ); |
132 | 132 | |
133 | - while ( $record = $import_csv->get_record() ) { |
|
133 | + while ($record = $import_csv->get_record()) { |
|
134 | 134 | $success = false; |
135 | 135 | // don't import empty records |
136 | - if( count( array_unique( $record ) ) < 2 ) continue; |
|
136 | + if (count(array_unique($record)) < 2) continue; |
|
137 | 137 | |
138 | - if(strtolower($record['account_expires']) == 'never') $record['account_expires'] = -1; |
|
138 | + if (strtolower($record['account_expires']) == 'never') $record['account_expires'] = -1; |
|
139 | 139 | importexport_import_csv::convert($record, admin_egw_user_record::$types, 'admin', $lookups); |
140 | 140 | |
141 | - if ( $_definition->plugin_options['conditions'] ) { |
|
142 | - foreach ( $_definition->plugin_options['conditions'] as $condition ) { |
|
143 | - switch ( $condition['type'] ) { |
|
141 | + if ($_definition->plugin_options['conditions']) { |
|
142 | + foreach ($_definition->plugin_options['conditions'] as $condition) { |
|
143 | + switch ($condition['type']) { |
|
144 | 144 | // exists |
145 | 145 | case 'exists' : |
146 | 146 | $accounts = array(); |
147 | 147 | // Skip the search if the field is empty |
148 | - if($record[$condition['string']] !== '') |
|
148 | + if ($record[$condition['string']] !== '') |
|
149 | 149 | { |
150 | 150 | $accounts = $GLOBALS['egw']->accounts->search(array( |
151 | 151 | 'type' => 'accounts', |
@@ -154,20 +154,20 @@ discard block |
||
154 | 154 | )); |
155 | 155 | } |
156 | 156 | // Search looks in the given field, but doesn't do an exact match |
157 | - foreach ( (array)$accounts as $key => $account ) |
|
157 | + foreach ((array)$accounts as $key => $account) |
|
158 | 158 | { |
159 | - if($account[$condition['string']] != $record[$condition['string']]) unset($accounts[$key]); |
|
159 | + if ($account[$condition['string']] != $record[$condition['string']]) unset($accounts[$key]); |
|
160 | 160 | } |
161 | - if ( is_array( $accounts ) && count( $accounts ) >= 1 ) { |
|
161 | + if (is_array($accounts) && count($accounts) >= 1) { |
|
162 | 162 | // apply action to all contacts matching this exists condition |
163 | 163 | $action = $condition['true']; |
164 | - foreach ( (array)$accounts as $account ) { |
|
164 | + foreach ((array)$accounts as $account) { |
|
165 | 165 | $record['account_id'] = $account['account_id']; |
166 | - $success = $this->action( $action['action'], $record, $import_csv->get_current_position() ); |
|
166 | + $success = $this->action($action['action'], $record, $import_csv->get_current_position()); |
|
167 | 167 | } |
168 | 168 | } else { |
169 | 169 | $action = $condition['false']; |
170 | - $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
|
170 | + $success = ($this->action($action['action'], $record, $import_csv->get_current_position())); |
|
171 | 171 | } |
172 | 172 | break; |
173 | 173 | |
@@ -180,9 +180,9 @@ discard block |
||
180 | 180 | } |
181 | 181 | } else { |
182 | 182 | // unconditional insert |
183 | - $success = $this->action( 'insert', $record, $import_csv->get_current_position() ); |
|
183 | + $success = $this->action('insert', $record, $import_csv->get_current_position()); |
|
184 | 184 | } |
185 | - if($success) $count++; |
|
185 | + if ($success) $count++; |
|
186 | 186 | } |
187 | 187 | return $count; |
188 | 188 | } |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | * @param array $_data contact data for the action |
195 | 195 | * @return bool success or not |
196 | 196 | */ |
197 | - private function action ( $_action, $_data, $record_num = 0 ) { |
|
197 | + private function action($_action, $_data, $record_num = 0) { |
|
198 | 198 | switch ($_action) { |
199 | 199 | case 'none' : |
200 | 200 | return true; |
@@ -203,8 +203,8 @@ discard block |
||
203 | 203 | $_data['account_expires'] = $_action == 'disable' ? 'already' : ''; |
204 | 204 | case 'create' : |
205 | 205 | case 'update' : |
206 | - $command = new admin_cmd_edit_user(($_action=='create'?null:$_data['account_lid']), $_data); |
|
207 | - if($this->dry_run) { |
|
206 | + $command = new admin_cmd_edit_user(($_action == 'create' ? null : $_data['account_lid']), $_data); |
|
207 | + if ($this->dry_run) { |
|
208 | 208 | $this->results[$_action]++; |
209 | 209 | return true; |
210 | 210 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * @param string|int $account =null account name or id |
25 | 25 | * @param array|string $apps =null app-names |
26 | 26 | */ |
27 | - function __construct($allow,$account=null,$apps=null) |
|
27 | + function __construct($allow, $account = null, $apps = null) |
|
28 | 28 | { |
29 | 29 | if (!is_array($allow)) |
30 | 30 | { |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | } |
37 | 37 | if (isset($allow['apps']) && !is_array($allow['apps'])) |
38 | 38 | { |
39 | - $allow['apps'] = explode(',',$allow['apps']); |
|
39 | + $allow['apps'] = explode(',', $allow['apps']); |
|
40 | 40 | } |
41 | 41 | admin_cmd::__construct($allow); |
42 | 42 | } |
@@ -50,11 +50,11 @@ discard block |
||
50 | 50 | * @throws Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!",$this->account),15); |
51 | 51 | * @throws Api\Exception\WrongUserinput(lang("Application '%1' not found (maybe not installed or misspelled)!",$name),8); |
52 | 52 | */ |
53 | - protected function exec($check_only=false) |
|
53 | + protected function exec($check_only = false) |
|
54 | 54 | { |
55 | 55 | $account_id = admin_cmd::parse_account($this->account); |
56 | 56 | // check creator is still admin and not explicitly forbidden to edit accounts/groups |
57 | - if ($this->creator) $this->_check_admin($account_id > 0 ? 'account_access' : 'group_access',16); |
|
57 | + if ($this->creator) $this->_check_admin($account_id > 0 ? 'account_access' : 'group_access', 16); |
|
58 | 58 | |
59 | 59 | $apps = admin_cmd::parse_apps($this->apps); |
60 | 60 | |
@@ -62,15 +62,15 @@ discard block |
||
62 | 62 | |
63 | 63 | //echo "account=$this->account, account_id=$account_id, apps: ".implode(', ',$apps)."\n"; |
64 | 64 | admin_cmd::_instanciate_acl($account_id); |
65 | - foreach($apps as $app) |
|
65 | + foreach ($apps as $app) |
|
66 | 66 | { |
67 | 67 | if ($this->allow) |
68 | 68 | { |
69 | - admin_cmd::$acl->add_repository($app,'run',$account_id,1); |
|
69 | + admin_cmd::$acl->add_repository($app, 'run', $account_id, 1); |
|
70 | 70 | } |
71 | 71 | else |
72 | 72 | { |
73 | - admin_cmd::$acl->delete_repository($app,'run',$account_id); |
|
73 | + admin_cmd::$acl->delete_repository($app, 'run', $account_id); |
|
74 | 74 | } |
75 | 75 | } |
76 | 76 | return lang('Applications run rights updated.'); |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | */ |
84 | 84 | function __tostring() |
85 | 85 | { |
86 | - return lang('%1 rights for %2 and applications %3',$this->allow ? lang('Grant') : lang('Remove'), |
|
87 | - admin_cmd::display_account($this->account),implode(', ',$this->apps)); |
|
86 | + return lang('%1 rights for %2 and applications %3', $this->allow ? lang('Grant') : lang('Remove'), |
|
87 | + admin_cmd::display_account($this->account), implode(', ', $this->apps)); |
|
88 | 88 | } |
89 | 89 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param egw_record $_definition |
23 | 23 | */ |
24 | - public function export( $_stream, importexport_definition $_definition) { |
|
24 | + public function export($_stream, importexport_definition $_definition) { |
|
25 | 25 | $options = $_definition->plugin_options; |
26 | 26 | |
27 | 27 | $query = array( |
@@ -40,12 +40,12 @@ discard block |
||
40 | 40 | // $_record is an array, that's what search() returns |
41 | 41 | foreach ($selection as $_record) { |
42 | 42 | $record = new admin_egw_group_record($_record); |
43 | - if($options['convert']) { |
|
43 | + if ($options['convert']) { |
|
44 | 44 | importexport_export_csv::convert($record, admin_egw_group_record::$types, 'admin', $lookups); |
45 | 45 | } else { |
46 | 46 | // Implode arrays, so they don't say 'Array' |
47 | - foreach($record->get_record_array() as $key => $value) { |
|
48 | - if(is_array($value)) $record->$key = implode(',', $value); |
|
47 | + foreach ($record->get_record_array() as $key => $value) { |
|
48 | + if (is_array($value)) $record->$key = implode(',', $value); |
|
49 | 49 | } |
50 | 50 | } |
51 | 51 | $export_object->export_record($record); |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | 'List config settings' => 1, |
15 | 15 | 'Change config settings' => 2 |
16 | 16 | ) |
17 | -); // added and working ralfbecker |
|
17 | +); // added and working ralfbecker |
|
18 | 18 | |
19 | 19 | $GLOBALS['acl_manager']['admin']['account_access'] = array( |
20 | 20 | 'name' => 'Deny access to user accounts', |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | 'Delete account' => 32, |
28 | 28 | 'change ACL Rights' => 64 |
29 | 29 | ) |
30 | -); // was already there and seems to work ralfbecker |
|
30 | +); // was already there and seems to work ralfbecker |
|
31 | 31 | |
32 | 32 | $GLOBALS['acl_manager']['admin']['group_access'] = array( |
33 | 33 | 'name' => 'Deny access to groups', |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | 'Edit group' => 16, |
40 | 40 | 'Delete group' => 32 |
41 | 41 | ) |
42 | -); // was already there and seems to work ralfbecker |
|
42 | +); // was already there and seems to work ralfbecker |
|
43 | 43 | |
44 | 44 | $GLOBALS['acl_manager']['admin']['applications_acc'] = array( |
45 | 45 | 'name' => 'Deny access to applications', |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | */ |
53 | 53 | 'Register application hooks' => 16 |
54 | 54 | ) |
55 | -); // added and working ralfbecker |
|
55 | +); // added and working ralfbecker |
|
56 | 56 | |
57 | 57 | $GLOBALS['acl_manager']['admin']['global_categorie'] = array( |
58 | 58 | 'name' => 'Deny access to global categories', |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | 'Delete category' => 32, |
66 | 66 | 'Add sub-category' => 64 |
67 | 67 | ) |
68 | -); // added and working ralfbecker |
|
68 | +); // added and working ralfbecker |
|
69 | 69 | |
70 | 70 | $GLOBALS['acl_manager']['admin']['mainscreen_messa'] = array( |
71 | 71 | 'name' => 'Deny access to mainscreen message', |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | 'Main screen message' => 1, |
74 | 74 | 'Login message' => 2 |
75 | 75 | ) |
76 | -); // added and working ralfbecker |
|
76 | +); // added and working ralfbecker |
|
77 | 77 | |
78 | 78 | $GLOBALS['acl_manager']['admin']['current_sessions'] = array( |
79 | 79 | 'name' => 'Deny access to current sessions', |
@@ -83,40 +83,40 @@ discard block |
||
83 | 83 | 'Show session IP address' => 4, |
84 | 84 | 'Kill session' => 8 |
85 | 85 | ) |
86 | -); // checked and working ralfbecker |
|
86 | +); // checked and working ralfbecker |
|
87 | 87 | |
88 | 88 | $GLOBALS['acl_manager']['admin']['access_log_acces'] = array( |
89 | 89 | 'name' => 'Deny access to access log', |
90 | 90 | 'rights' => array( |
91 | 91 | 'Show access log' => 1 |
92 | 92 | ) |
93 | -); // added and working ralfbecker |
|
93 | +); // added and working ralfbecker |
|
94 | 94 | |
95 | 95 | $GLOBALS['acl_manager']['admin']['error_log_access'] = array( |
96 | 96 | 'name' => 'Deny access to error log', |
97 | 97 | 'rights' => array( |
98 | 98 | 'Show error log' => 1 |
99 | 99 | ) |
100 | -); // added and working ralfbecker |
|
100 | +); // added and working ralfbecker |
|
101 | 101 | |
102 | 102 | $GLOBALS['acl_manager']['admin']['asyncservice_acc'] = array( |
103 | 103 | 'name' => 'Deny access to asynchronous timed services', |
104 | 104 | 'rights' => array( |
105 | 105 | 'Asynchronous timed services' => 1 |
106 | 106 | ) |
107 | -); // added and working ralfbecker |
|
107 | +); // added and working ralfbecker |
|
108 | 108 | |
109 | 109 | $GLOBALS['acl_manager']['admin']['db_backup_access'] = array( |
110 | 110 | 'name' => 'Deny access to DB backup and restore', |
111 | 111 | 'rights' => array( |
112 | 112 | 'DB backup and restore' => 1 |
113 | 113 | ) |
114 | -); // added and working ralfbecker |
|
114 | +); // added and working ralfbecker |
|
115 | 115 | |
116 | 116 | $GLOBALS['acl_manager']['admin']['info_access'] = array( |
117 | 117 | 'name' => 'Deny access to phpinfo', |
118 | 118 | 'rights' => array( |
119 | 119 | 'Show phpinfo()' => 1 |
120 | 120 | ) |
121 | -); // added and working ralfbecker |
|
121 | +); // added and working ralfbecker |
|
122 | 122 |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @param array $data =array() default parm from parent class, no real parameters |
26 | 26 | */ |
27 | - function __construct($data=array()) |
|
27 | + function __construct($data = array()) |
|
28 | 28 | { |
29 | 29 | admin_cmd::__construct($data); |
30 | 30 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * @param boolean $check_only =false only run the checks (and throw the exceptions), but not the command itself |
36 | 36 | * @return string success message |
37 | 37 | */ |
38 | - protected function exec($check_only=false) |
|
38 | + protected function exec($check_only = false) |
|
39 | 39 | { |
40 | 40 | if ($check_only) return true; |
41 | 41 |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | if (($f = $this->db_backup->fopen_backup())) |
29 | 29 | { |
30 | 30 | $this->db_backup->backup($f); |
31 | - if(is_resource($f)) |
|
31 | + if (is_resource($f)) |
|
32 | 32 | fclose($f); |
33 | 33 | /* Remove old backups. */ |
34 | 34 | $this->db_backup->housekeeping(); |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | function index() |
42 | 42 | { |
43 | 43 | $tpl_root = EGW_SERVER_ROOT.'/setup/templates/default'; |
44 | - $self = $GLOBALS['egw']->link('/index.php',array('menuaction'=>'admin.admin_db_backup.index')); |
|
44 | + $self = $GLOBALS['egw']->link('/index.php', array('menuaction'=>'admin.admin_db_backup.index')); |
|
45 | 45 | Api\Translation::add_app('setup'); |
46 | 46 | Api\Header\ContentSecurityPolicy::add('script-src', 'unsafe-inline'); |
47 | 47 |
@@ -21,13 +21,13 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param egw_record $_definition |
23 | 23 | */ |
24 | - public function export( $_stream, importexport_definition $_definition) { |
|
24 | + public function export($_stream, importexport_definition $_definition) { |
|
25 | 25 | $options = $_definition->plugin_options; |
26 | 26 | |
27 | 27 | $query = array( |
28 | 28 | 'type' => 'accounts', |
29 | 29 | ); |
30 | - if($options['selection']['group_id']) { |
|
30 | + if ($options['selection']['group_id']) { |
|
31 | 31 | $query['type'] = (int)$options['selection']['group_id']; |
32 | 32 | } |
33 | 33 | $selection = $GLOBALS['egw']->accounts->search($query); |
@@ -43,14 +43,14 @@ discard block |
||
43 | 43 | // $_record is an array, that's what search() returns |
44 | 44 | foreach ($selection as $_record) { |
45 | 45 | $record = new admin_egw_user_record($_record); |
46 | - if($options['convert']) { |
|
46 | + if ($options['convert']) { |
|
47 | 47 | $never_expires = ($record->account_expires == -1); |
48 | 48 | importexport_export_csv::convert($record, admin_egw_user_record::$types, 'admin', $lookups); |
49 | - if($never_expires) $record->account_expires = 'never'; // Has to be 'never' for admin_cmd_edit_user to parse it |
|
49 | + if ($never_expires) $record->account_expires = 'never'; // Has to be 'never' for admin_cmd_edit_user to parse it |
|
50 | 50 | } else { |
51 | 51 | // Implode arrays, so they don't say 'Array' |
52 | - foreach($record->get_record_array() as $key => $value) { |
|
53 | - if(is_array($value)) $record->$key = implode(',', $value); |
|
52 | + foreach ($record->get_record_array() as $key => $value) { |
|
53 | + if (is_array($value)) $record->$key = implode(',', $value); |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | $export_object->export_record($record); |
@@ -15,15 +15,15 @@ discard block |
||
15 | 15 | /** |
16 | 16 | * class import_csv for admin (groups) |
17 | 17 | */ |
18 | -class admin_import_groups_csv implements importexport_iface_import_plugin { |
|
18 | +class admin_import_groups_csv implements importexport_iface_import_plugin { |
|
19 | 19 | |
20 | 20 | private static $plugin_options = array( |
21 | - 'fieldsep', // char |
|
22 | - 'charset', // string |
|
21 | + 'fieldsep', // char |
|
22 | + 'charset', // string |
|
23 | 23 | 'num_header_lines', // int number of header lines |
24 | 24 | 'field_conversion', // array( $csv_col_num => conversion) |
25 | - 'field_mapping', // array( $csv_col_num => adb_filed) |
|
26 | - 'conditions', /* => array containing condition arrays: |
|
25 | + 'field_mapping', // array( $csv_col_num => adb_filed) |
|
26 | + 'conditions', /* => array containing condition arrays: |
|
27 | 27 | 'type' => exists, // exists |
28 | 28 | 'string' => '#kundennummer', |
29 | 29 | 'true' => array( |
@@ -40,14 +40,14 @@ discard block |
||
40 | 40 | /** |
41 | 41 | * actions which could be done to data entries |
42 | 42 | */ |
43 | - protected static $actions = array( 'none', 'update', 'create', 'delete'); |
|
43 | + protected static $actions = array('none', 'update', 'create', 'delete'); |
|
44 | 44 | |
45 | 45 | /** |
46 | 46 | * conditions for actions |
47 | 47 | * |
48 | 48 | * @var array |
49 | 49 | */ |
50 | - protected static $conditions = array( 'exists' ); |
|
50 | + protected static $conditions = array('exists'); |
|
51 | 51 | |
52 | 52 | /** |
53 | 53 | * @var definition |
@@ -80,8 +80,8 @@ discard block |
||
80 | 80 | * @param string $_charset |
81 | 81 | * @param definition $_definition |
82 | 82 | */ |
83 | - public function import( $_stream, importexport_definition $_definition ) { |
|
84 | - $import_csv = new importexport_import_csv( $_stream, array( |
|
83 | + public function import($_stream, importexport_definition $_definition) { |
|
84 | + $import_csv = new importexport_import_csv($_stream, array( |
|
85 | 85 | 'fieldsep' => $_definition->plugin_options['fieldsep'], |
86 | 86 | 'charset' => $_definition->plugin_options['charset'], |
87 | 87 | )); |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | $this->definition = $_definition; |
90 | 90 | |
91 | 91 | // dry run? |
92 | - $this->dry_run = isset( $_definition->plugin_options['dry_run'] ) ? $_definition->plugin_options['dry_run'] : false; |
|
92 | + $this->dry_run = isset($_definition->plugin_options['dry_run']) ? $_definition->plugin_options['dry_run'] : false; |
|
93 | 93 | |
94 | 94 | // set FieldMapping. |
95 | 95 | $import_csv->mapping = $_definition->plugin_options['field_mapping']; |
@@ -98,9 +98,9 @@ discard block |
||
98 | 98 | $import_csv->conversion = $_definition->plugin_options['field_conversion']; |
99 | 99 | |
100 | 100 | //check if file has a header lines |
101 | - if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0) { |
|
101 | + if (isset($_definition->plugin_options['num_header_lines']) && $_definition->plugin_options['num_header_lines'] > 0) { |
|
102 | 102 | $import_csv->skip_records($_definition->plugin_options['num_header_lines']); |
103 | - } elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) { |
|
103 | + } elseif (isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) { |
|
104 | 104 | // First method is preferred |
105 | 105 | $import_csv->skip_records(1); |
106 | 106 | } |
@@ -112,22 +112,22 @@ discard block |
||
112 | 112 | // Failures |
113 | 113 | $this->errors = array(); |
114 | 114 | |
115 | - while ( $record = $import_csv->get_record() ) { |
|
115 | + while ($record = $import_csv->get_record()) { |
|
116 | 116 | $success = false; |
117 | 117 | // don't import empty records |
118 | - if( count( array_unique( $record ) ) < 2 ) continue; |
|
118 | + if (count(array_unique($record)) < 2) continue; |
|
119 | 119 | |
120 | 120 | importexport_import_csv::convert($record, admin_egw_group_record::$types, 'admin'); |
121 | 121 | |
122 | - if ( $_definition->plugin_options['conditions'] ) { |
|
123 | - foreach ( $_definition->plugin_options['conditions'] as $condition ) { |
|
124 | - switch ( $condition['type'] ) { |
|
122 | + if ($_definition->plugin_options['conditions']) { |
|
123 | + foreach ($_definition->plugin_options['conditions'] as $condition) { |
|
124 | + switch ($condition['type']) { |
|
125 | 125 | // exists |
126 | 126 | case 'exists' : |
127 | 127 | $accounts = array(); |
128 | 128 | |
129 | 129 | // Skip the search if the field is empty |
130 | - if($record[$condition['string']] !== '') { |
|
130 | + if ($record[$condition['string']] !== '') { |
|
131 | 131 | |
132 | 132 | $accounts = $GLOBALS['egw']->accounts->search(array( |
133 | 133 | 'type' => 'groups', |
@@ -136,25 +136,25 @@ discard block |
||
136 | 136 | )); |
137 | 137 | } |
138 | 138 | // Search looks in the given field, but doesn't do an exact match |
139 | - foreach ( (array)$accounts as $key => $account ) |
|
139 | + foreach ((array)$accounts as $key => $account) |
|
140 | 140 | { |
141 | - if($account[$condition['string']] != $record[$condition['string']]) unset($accounts[$key]); |
|
141 | + if ($account[$condition['string']] != $record[$condition['string']]) unset($accounts[$key]); |
|
142 | 142 | } |
143 | - if ( is_array( $accounts ) && count( $accounts ) >= 1 ) { |
|
143 | + if (is_array($accounts) && count($accounts) >= 1) { |
|
144 | 144 | $account = current($accounts); |
145 | 145 | // apply action to all contacts matching this exists condition |
146 | 146 | $action = $condition['true']; |
147 | - foreach ( (array)$accounts as $account ) { |
|
147 | + foreach ((array)$accounts as $account) { |
|
148 | 148 | // Read full account, and copy needed info for accounts->save() |
149 | 149 | $account = $GLOBALS['egw']->accounts->read($account['account_id']); |
150 | 150 | $record['account_id'] = $account['account_id']; |
151 | 151 | $record['account_firstname'] = $account['account_firstname']; |
152 | 152 | $record['account_lastname'] = $account['account_lastname']; |
153 | - $success = $this->action( $action['action'], $record, $import_csv->get_current_position() ); |
|
153 | + $success = $this->action($action['action'], $record, $import_csv->get_current_position()); |
|
154 | 154 | } |
155 | 155 | } else { |
156 | 156 | $action = $condition['false']; |
157 | - $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
|
157 | + $success = ($this->action($action['action'], $record, $import_csv->get_current_position())); |
|
158 | 158 | } |
159 | 159 | break; |
160 | 160 | |
@@ -167,9 +167,9 @@ discard block |
||
167 | 167 | } |
168 | 168 | } else { |
169 | 169 | // unconditional insert |
170 | - $success = $this->action( 'insert', $record, $import_csv->get_current_position() ); |
|
170 | + $success = $this->action('insert', $record, $import_csv->get_current_position()); |
|
171 | 171 | } |
172 | - if($success) $count++; |
|
172 | + if ($success) $count++; |
|
173 | 173 | } |
174 | 174 | return $count; |
175 | 175 | } |
@@ -181,18 +181,18 @@ discard block |
||
181 | 181 | * @param array $_data contact data for the action |
182 | 182 | * @return bool success or not |
183 | 183 | */ |
184 | - private function action ( $_action, $_data, $record_num = 0 ) { |
|
184 | + private function action($_action, $_data, $record_num = 0) { |
|
185 | 185 | switch ($_action) { |
186 | 186 | case 'none' : |
187 | 187 | return true; |
188 | 188 | case 'update' : |
189 | 189 | case 'create' : |
190 | - if(count($_data['account_members']) < 1) { |
|
190 | + if (count($_data['account_members']) < 1) { |
|
191 | 191 | $this->errors[$record_num] = lang('You must select at least one group member.'); |
192 | 192 | return false; |
193 | 193 | } |
194 | 194 | $command = new admin_cmd_edit_group($_action == 'create' ? false : $_data['account_lid'], $_data); |
195 | - if($this->dry_run) { |
|
195 | + if ($this->dry_run) { |
|
196 | 196 | $this->results[$_action]++; |
197 | 197 | return true; |
198 | 198 | } |