@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | /** |
20 | 20 | * Exports records as defined in $_definition |
21 | 21 | * |
22 | - * @param egw_record $_definition |
|
22 | + * @param importexport_definition $_definition |
|
23 | 23 | */ |
24 | 24 | public function export( $_stream, importexport_definition $_definition) { |
25 | 25 | $options = $_definition->plugin_options; |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * return html for options. |
89 | 89 | * this way the plugin has all opportunities for options tab |
90 | 90 | * |
91 | - * @return string html |
|
91 | + * @return boolean html |
|
92 | 92 | */ |
93 | 93 | public function get_options_etpl() { |
94 | 94 | return false; |
@@ -81,8 +81,8 @@ |
||
81 | 81 | } |
82 | 82 | |
83 | 83 | public static function get_mimetype() { |
84 | - return 'text/csv'; |
|
85 | - } |
|
84 | + return 'text/csv'; |
|
85 | + } |
|
86 | 86 | |
87 | 87 | /** |
88 | 88 | * return html for options. |
@@ -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); |
@@ -21,7 +21,8 @@ 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 | 26 | $options = $_definition->plugin_options; |
26 | 27 | |
27 | 28 | $query = array( |
@@ -38,14 +39,22 @@ discard block |
||
38 | 39 | ); |
39 | 40 | |
40 | 41 | // $_record is an array, that's what search() returns |
41 | - foreach ($selection as $_record) { |
|
42 | + foreach ($selection as $_record) |
|
43 | + { |
|
42 | 44 | $record = new admin_egw_group_record($_record); |
43 | - if($options['convert']) { |
|
45 | + if($options['convert']) |
|
46 | + { |
|
44 | 47 | importexport_export_csv::convert($record, admin_egw_group_record::$types, 'admin', $lookups); |
45 | - } else { |
|
48 | + } |
|
49 | + else |
|
50 | + { |
|
46 | 51 | // 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); |
|
52 | + foreach($record->get_record_array() as $key => $value) |
|
53 | + { |
|
54 | + if(is_array($value)) |
|
55 | + { |
|
56 | + $record->$key = implode(',', $value); |
|
57 | + } |
|
49 | 58 | } |
50 | 59 | } |
51 | 60 | $export_object->export_record($record); |
@@ -58,7 +67,8 @@ discard block |
||
58 | 67 | * |
59 | 68 | * @return string name |
60 | 69 | */ |
61 | - public static function get_name() { |
|
70 | + public static function get_name() |
|
71 | + { |
|
62 | 72 | return lang('Group CSV export'); |
63 | 73 | } |
64 | 74 | |
@@ -67,7 +77,8 @@ discard block |
||
67 | 77 | * |
68 | 78 | * @return string descriprion |
69 | 79 | */ |
70 | - public static function get_description() { |
|
80 | + public static function get_description() |
|
81 | + { |
|
71 | 82 | return lang("Exports groups into a CSV File. "); |
72 | 83 | } |
73 | 84 | |
@@ -76,11 +87,13 @@ discard block |
||
76 | 87 | * |
77 | 88 | * @return string suffix |
78 | 89 | */ |
79 | - public static function get_filesuffix() { |
|
90 | + public static function get_filesuffix() |
|
91 | + { |
|
80 | 92 | return 'csv'; |
81 | 93 | } |
82 | 94 | |
83 | - public static function get_mimetype() { |
|
95 | + public static function get_mimetype() |
|
96 | + { |
|
84 | 97 | return 'text/csv'; |
85 | 98 | } |
86 | 99 | |
@@ -90,7 +103,8 @@ discard block |
||
90 | 103 | * |
91 | 104 | * @return string html |
92 | 105 | */ |
93 | - public function get_options_etpl() { |
|
106 | + public function get_options_etpl() |
|
107 | + { |
|
94 | 108 | return false; |
95 | 109 | } |
96 | 110 | |
@@ -98,7 +112,8 @@ discard block |
||
98 | 112 | * returns slectors of this plugin via xajax |
99 | 113 | * |
100 | 114 | */ |
101 | - public function get_selectors_etpl() { |
|
115 | + public function get_selectors_etpl() |
|
116 | + { |
|
102 | 117 | return array( |
103 | 118 | 'preserv' => array('no_error_for_no_selection'), |
104 | 119 | ); |
@@ -77,8 +77,7 @@ |
||
77 | 77 | /** |
78 | 78 | * imports entries according to given definition object. |
79 | 79 | * @param resource $_stream |
80 | - * @param string $_charset |
|
81 | - * @param definition $_definition |
|
80 | + * @param importexport_definition $_definition |
|
82 | 81 | */ |
83 | 82 | public function import( $_stream, importexport_definition $_definition ) { |
84 | 83 | $import_csv = new importexport_import_csv( $_stream, array( |
@@ -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 | } |
@@ -15,7 +15,8 @@ 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 | 21 | private static $plugin_options = array( |
21 | 22 | 'fieldsep', // char |
@@ -80,7 +81,8 @@ discard block |
||
80 | 81 | * @param string $_charset |
81 | 82 | * @param definition $_definition |
82 | 83 | */ |
83 | - public function import( $_stream, importexport_definition $_definition ) { |
|
84 | + public function import( $_stream, importexport_definition $_definition ) |
|
85 | + { |
|
84 | 86 | $import_csv = new importexport_import_csv( $_stream, array( |
85 | 87 | 'fieldsep' => $_definition->plugin_options['fieldsep'], |
86 | 88 | 'charset' => $_definition->plugin_options['charset'], |
@@ -98,9 +100,12 @@ discard block |
||
98 | 100 | $import_csv->conversion = $_definition->plugin_options['field_conversion']; |
99 | 101 | |
100 | 102 | //check if file has a header lines |
101 | - if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0) { |
|
103 | + if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0) |
|
104 | + { |
|
102 | 105 | $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']) { |
|
106 | + } |
|
107 | + elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) |
|
108 | + { |
|
104 | 109 | // First method is preferred |
105 | 110 | $import_csv->skip_records(1); |
106 | 111 | } |
@@ -112,22 +117,30 @@ discard block |
||
112 | 117 | // Failures |
113 | 118 | $this->errors = array(); |
114 | 119 | |
115 | - while ( $record = $import_csv->get_record() ) { |
|
120 | + while ( $record = $import_csv->get_record() ) |
|
121 | + { |
|
116 | 122 | $success = false; |
117 | 123 | // don't import empty records |
118 | - if( count( array_unique( $record ) ) < 2 ) continue; |
|
124 | + if( count( array_unique( $record ) ) < 2 ) |
|
125 | + { |
|
126 | + continue; |
|
127 | + } |
|
119 | 128 | |
120 | 129 | importexport_import_csv::convert($record, admin_egw_group_record::$types, 'admin'); |
121 | 130 | |
122 | - if ( $_definition->plugin_options['conditions'] ) { |
|
123 | - foreach ( $_definition->plugin_options['conditions'] as $condition ) { |
|
124 | - switch ( $condition['type'] ) { |
|
131 | + if ( $_definition->plugin_options['conditions'] ) |
|
132 | + { |
|
133 | + foreach ( $_definition->plugin_options['conditions'] as $condition ) |
|
134 | + { |
|
135 | + switch ( $condition['type'] ) |
|
136 | + { |
|
125 | 137 | // exists |
126 | 138 | case 'exists' : |
127 | 139 | $accounts = array(); |
128 | 140 | |
129 | 141 | // Skip the search if the field is empty |
130 | - if($record[$condition['string']] !== '') { |
|
142 | + if($record[$condition['string']] !== '') |
|
143 | + { |
|
131 | 144 | |
132 | 145 | $accounts = $GLOBALS['egw']->accounts->search(array( |
133 | 146 | 'type' => 'groups', |
@@ -138,13 +151,18 @@ discard block |
||
138 | 151 | // Search looks in the given field, but doesn't do an exact match |
139 | 152 | foreach ( (array)$accounts as $key => $account ) |
140 | 153 | { |
141 | - if($account[$condition['string']] != $record[$condition['string']]) unset($accounts[$key]); |
|
154 | + if($account[$condition['string']] != $record[$condition['string']]) |
|
155 | + { |
|
156 | + unset($accounts[$key]); |
|
157 | + } |
|
142 | 158 | } |
143 | - if ( is_array( $accounts ) && count( $accounts ) >= 1 ) { |
|
159 | + if ( is_array( $accounts ) && count( $accounts ) >= 1 ) |
|
160 | + { |
|
144 | 161 | $account = current($accounts); |
145 | 162 | // apply action to all contacts matching this exists condition |
146 | 163 | $action = $condition['true']; |
147 | - foreach ( (array)$accounts as $account ) { |
|
164 | + foreach ( (array)$accounts as $account ) |
|
165 | + { |
|
148 | 166 | // Read full account, and copy needed info for accounts->save() |
149 | 167 | $account = $GLOBALS['egw']->accounts->read($account['account_id']); |
150 | 168 | $record['account_id'] = $account['account_id']; |
@@ -152,7 +170,9 @@ discard block |
||
152 | 170 | $record['account_lastname'] = $account['account_lastname']; |
153 | 171 | $success = $this->action( $action['action'], $record, $import_csv->get_current_position() ); |
154 | 172 | } |
155 | - } else { |
|
173 | + } |
|
174 | + else |
|
175 | + { |
|
156 | 176 | $action = $condition['false']; |
157 | 177 | $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
158 | 178 | } |
@@ -162,13 +182,21 @@ discard block |
||
162 | 182 | default : |
163 | 183 | die('condition / action not supported!!!'); |
164 | 184 | } |
165 | - if ($action['last']) break; |
|
185 | + if ($action['last']) |
|
186 | + { |
|
187 | + break; |
|
188 | + } |
|
166 | 189 | } |
167 | - } else { |
|
190 | + } |
|
191 | + else |
|
192 | + { |
|
168 | 193 | // unconditional insert |
169 | 194 | $success = $this->action( 'insert', $record, $import_csv->get_current_position() ); |
170 | 195 | } |
171 | - if($success) $count++; |
|
196 | + if($success) |
|
197 | + { |
|
198 | + $count++; |
|
199 | + } |
|
172 | 200 | } |
173 | 201 | return $count; |
174 | 202 | } |
@@ -180,24 +208,29 @@ discard block |
||
180 | 208 | * @param array $_data contact data for the action |
181 | 209 | * @return bool success or not |
182 | 210 | */ |
183 | - private function action ( $_action, $_data, $record_num = 0 ) { |
|
184 | - switch ($_action) { |
|
211 | + private function action ( $_action, $_data, $record_num = 0 ) |
|
212 | + { |
|
213 | + switch ($_action) |
|
214 | + { |
|
185 | 215 | case 'none' : |
186 | 216 | return true; |
187 | 217 | case 'update' : |
188 | 218 | case 'create' : |
189 | - if(count($_data['account_members']) < 1) { |
|
219 | + if(count($_data['account_members']) < 1) |
|
220 | + { |
|
190 | 221 | $this->errors[$record_num] = lang('You must select at least one group member.'); |
191 | 222 | return false; |
192 | 223 | } |
193 | 224 | $command = new admin_cmd_edit_group($_action == 'create' ? false : $_data['account_lid'], $_data); |
194 | - if($this->dry_run) { |
|
225 | + if($this->dry_run) |
|
226 | + { |
|
195 | 227 | $this->results[$_action]++; |
196 | 228 | return true; |
197 | 229 | } |
198 | 230 | try { |
199 | 231 | $command->run(); |
200 | - } catch (Exception $e) { |
|
232 | + } |
|
233 | + catch (Exception $e) { |
|
201 | 234 | $this->errors[$record_num] = $e->getMessage(); |
202 | 235 | return false; |
203 | 236 | } |
@@ -214,7 +247,8 @@ discard block |
||
214 | 247 | * |
215 | 248 | * @return string name |
216 | 249 | */ |
217 | - public static function get_name() { |
|
250 | + public static function get_name() |
|
251 | + { |
|
218 | 252 | return lang('Group CSV import'); |
219 | 253 | } |
220 | 254 | |
@@ -223,7 +257,8 @@ discard block |
||
223 | 257 | * |
224 | 258 | * @return string descriprion |
225 | 259 | */ |
226 | - public static function get_description() { |
|
260 | + public static function get_description() |
|
261 | + { |
|
227 | 262 | return lang("Creates / updates user groups from CSV file"); |
228 | 263 | } |
229 | 264 | |
@@ -232,7 +267,8 @@ discard block |
||
232 | 267 | * |
233 | 268 | * @return string suffix (comma seperated) |
234 | 269 | */ |
235 | - public static function get_filesuffix() { |
|
270 | + public static function get_filesuffix() |
|
271 | + { |
|
236 | 272 | return 'csv'; |
237 | 273 | } |
238 | 274 | |
@@ -248,7 +284,8 @@ discard block |
||
248 | 284 | * preserv => array, |
249 | 285 | * ) |
250 | 286 | */ |
251 | - public function get_options_etpl() { |
|
287 | + public function get_options_etpl() |
|
288 | + { |
|
252 | 289 | // lets do it! |
253 | 290 | } |
254 | 291 | |
@@ -257,7 +294,8 @@ discard block |
||
257 | 294 | * |
258 | 295 | * @return string etemplate name |
259 | 296 | */ |
260 | - public function get_selectors_etpl() { |
|
297 | + public function get_selectors_etpl() |
|
298 | + { |
|
261 | 299 | // lets do it! |
262 | 300 | } |
263 | 301 | |
@@ -269,7 +307,8 @@ discard block |
||
269 | 307 | * record_# => warning message |
270 | 308 | * ) |
271 | 309 | */ |
272 | - public function get_warnings() { |
|
310 | + public function get_warnings() |
|
311 | + { |
|
273 | 312 | return $this->warnings; |
274 | 313 | } |
275 | 314 | |
@@ -281,7 +320,8 @@ discard block |
||
281 | 320 | * record_# => error message |
282 | 321 | * ) |
283 | 322 | */ |
284 | - public function get_errors() { |
|
323 | + public function get_errors() |
|
324 | + { |
|
285 | 325 | return $this->errors; |
286 | 326 | } |
287 | 327 | |
@@ -293,7 +333,8 @@ discard block |
||
293 | 333 | * action => record count |
294 | 334 | * ) |
295 | 335 | */ |
296 | - public function get_results() { |
|
336 | + public function get_results() |
|
337 | + { |
|
297 | 338 | return $this->results; |
298 | 339 | } |
299 | 340 | } |
@@ -291,7 +291,7 @@ |
||
291 | 291 | * Check if next submission is due, in which case we call submit and NOT return to the admin hook |
292 | 292 | * |
293 | 293 | * @param boolean $redirect should we redirect or return true |
294 | - * @return boolean true if statistic submission is due |
|
294 | + * @return boolean|null true if statistic submission is due |
|
295 | 295 | */ |
296 | 296 | public static function check($redirect=true) |
297 | 297 | { |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | const SUBMIT_URL = 'https://www.egroupware.org/usage-statistic'; |
31 | 31 | const STATISTIC_URL = 'http://www.egroupware.org/usage-statistic'; |
32 | 32 | |
33 | - const SUBMISION_RATE = 2592000; // 30 days |
|
33 | + const SUBMISION_RATE = 2592000; // 30 days |
|
34 | 34 | |
35 | 35 | /** |
36 | 36 | * Which methods of this class can be called as menuation |
@@ -46,27 +46,27 @@ discard block |
||
46 | 46 | * |
47 | 47 | * @param array $_content =null |
48 | 48 | */ |
49 | - public function submit($_content=null) |
|
49 | + public function submit($_content = null) |
|
50 | 50 | { |
51 | 51 | if (is_array($_content)) |
52 | 52 | { |
53 | 53 | $config = new Api\Config(self::CONFIG_APP); |
54 | 54 | if ($_content['postpone']) |
55 | 55 | { |
56 | - Api\Config::save_value(self::CONFIG_POSTPONE_SUBMIT,time()+$_content['postpone'],self::CONFIG_APP); |
|
56 | + Api\Config::save_value(self::CONFIG_POSTPONE_SUBMIT, time() + $_content['postpone'], self::CONFIG_APP); |
|
57 | 57 | $what = 'postpone'; |
58 | 58 | } |
59 | - elseif(!$_content['cancel']) |
|
59 | + elseif (!$_content['cancel']) |
|
60 | 60 | { |
61 | - Api\Config::save_value(self::CONFIG_LAST_SUBMIT,time(),self::CONFIG_APP); |
|
62 | - Api\Config::save_value(self::CONFIG_SUBMIT_ID,empty($_content['submit_id']) ? '***none***' : $_content['submit_id'],self::CONFIG_APP); |
|
63 | - Api\Config::save_value(self::CONFIG_COUNTRY,empty($_content['country']) ? '***multinational***' : $_content['country'],self::CONFIG_APP); |
|
64 | - Api\Config::save_value(self::CONFIG_USAGE_TYPE,$_content['usage_type'],self::CONFIG_APP); |
|
65 | - Api\Config::save_value(self::CONFIG_INSTALL_TYPE,$_content['install_type'],self::CONFIG_APP); |
|
66 | - Api\Config::save_value(self::CONFIG_POSTPONE_SUBMIT,null,self::CONFIG_APP); // remove evtl. postpone time |
|
61 | + Api\Config::save_value(self::CONFIG_LAST_SUBMIT, time(), self::CONFIG_APP); |
|
62 | + Api\Config::save_value(self::CONFIG_SUBMIT_ID, empty($_content['submit_id']) ? '***none***' : $_content['submit_id'], self::CONFIG_APP); |
|
63 | + Api\Config::save_value(self::CONFIG_COUNTRY, empty($_content['country']) ? '***multinational***' : $_content['country'], self::CONFIG_APP); |
|
64 | + Api\Config::save_value(self::CONFIG_USAGE_TYPE, $_content['usage_type'], self::CONFIG_APP); |
|
65 | + Api\Config::save_value(self::CONFIG_INSTALL_TYPE, $_content['install_type'], self::CONFIG_APP); |
|
66 | + Api\Config::save_value(self::CONFIG_POSTPONE_SUBMIT, null, self::CONFIG_APP); // remove evtl. postpone time |
|
67 | 67 | $what = 'submitted'; |
68 | 68 | } |
69 | - Egw::redirect_link('/admin/index.php','ajax=true&statistics='.($what ? $what : 'canceled'),'admin'); |
|
69 | + Egw::redirect_link('/admin/index.php', 'ajax=true&statistics='.($what ? $what : 'canceled'), 'admin'); |
|
70 | 70 | } |
71 | 71 | $sel_options['usage_type'] = array( |
72 | 72 | 'commercial' => lang('Commercial: all sorts of companies'), |
@@ -86,19 +86,19 @@ discard block |
||
86 | 86 | $sel_options['postpone'] = array( |
87 | 87 | //10 => '10 secs', |
88 | 88 | 3600 => lang('one hour'), |
89 | - 2*3600 => lang('two hours'), |
|
90 | - 24*3600 => lang('one day'), |
|
91 | - 2*24*3600 => lang('two days'), |
|
92 | - 7*24*3600 => lang('one week'), |
|
93 | - 14*24*3600 => lang('two weeks'), |
|
94 | - 30*24*3600 => lang('one month'), |
|
95 | - 60*24*3600 => lang('two months'), |
|
89 | + 2 * 3600 => lang('two hours'), |
|
90 | + 24 * 3600 => lang('one day'), |
|
91 | + 2 * 24 * 3600 => lang('two days'), |
|
92 | + 7 * 24 * 3600 => lang('one week'), |
|
93 | + 14 * 24 * 3600 => lang('two weeks'), |
|
94 | + 30 * 24 * 3600 => lang('one month'), |
|
95 | + 60 * 24 * 3600 => lang('two months'), |
|
96 | 96 | ); |
97 | 97 | $config = Api\Config::read(self::CONFIG_APP); |
98 | 98 | //_debug_array($config); |
99 | - $content = array_merge(self::gather_data(),array( |
|
99 | + $content = array_merge(self::gather_data(), array( |
|
100 | 100 | 'statistic_url' => self::STATISTIC_URL, |
101 | - 'submit_host' => parse_url(self::SUBMIT_URL,PHP_URL_HOST), |
|
101 | + 'submit_host' => parse_url(self::SUBMIT_URL, PHP_URL_HOST), |
|
102 | 102 | 'submit_url' => self::SUBMIT_URL, |
103 | 103 | 'last_submitted' => $config[self::CONFIG_LAST_SUBMIT], |
104 | 104 | )); |
@@ -125,12 +125,12 @@ discard block |
||
125 | 125 | $sel_options['install_type'] = array($content['install_type'] => $sel_options['install_type'][$content['install_type']]); |
126 | 126 | } |
127 | 127 | // else default to previous type |
128 | - elseif($config[self::CONFIG_INSTALL_TYPE]) |
|
128 | + elseif ($config[self::CONFIG_INSTALL_TYPE]) |
|
129 | 129 | { |
130 | 130 | $content['install_type'] = $config[self::CONFIG_INSTALL_TYPE]; |
131 | 131 | } |
132 | 132 | // check if we are due for a new submission |
133 | - if (!isset($config[self::CONFIG_LAST_SUBMIT]) || $config[self::CONFIG_LAST_SUBMIT ] <= time()-self::SUBMISION_RATE) |
|
133 | + if (!isset($config[self::CONFIG_LAST_SUBMIT]) || $config[self::CONFIG_LAST_SUBMIT] <= time() - self::SUBMISION_RATE) |
|
134 | 134 | { |
135 | 135 | // clear etemplate_exec_id and replace form.action, before submitting the form |
136 | 136 | $content['onclick'] = "return app.admin.submit_statistic(this.form,'$content[submit_url]');"; |
@@ -139,11 +139,11 @@ discard block |
||
139 | 139 | { |
140 | 140 | $readonlys['submit'] = $readonlys['postpone'] = true; |
141 | 141 | $content['msg'] = lang('Your last submission was less then %1 days ago!', |
142 | - ceil((time()-$config[self::CONFIG_LAST_SUBMIT])/24/3600)); |
|
142 | + ceil((time() - $config[self::CONFIG_LAST_SUBMIT]) / 24 / 3600)); |
|
143 | 143 | } |
144 | 144 | $GLOBALS['egw_info']['flags']['app_header'] = lang('Submit statistic information'); |
145 | 145 | $tmpl = new Etemplate('admin.statistics'); |
146 | - $tmpl->exec('admin.admin_statistics.submit',$content,$sel_options,$readonlys); |
|
146 | + $tmpl->exec('admin.admin_statistics.submit', $content, $sel_options, $readonlys); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | $data['version'] .= ' '.$GLOBALS['egw_info']['apps']['stylite']['version'].'EPL'; |
167 | 167 | } |
168 | 168 | // sessions in the last 30 days |
169 | - $data['sessions'] = $GLOBALS['egw']->db->query('SELECT COUNT(*) FROM egw_access_log WHERE li > '.(time()-30*24*3600))->fetchColumn(); |
|
169 | + $data['sessions'] = $GLOBALS['egw']->db->query('SELECT COUNT(*) FROM egw_access_log WHERE li > '.(time() - 30 * 24 * 3600))->fetchColumn(); |
|
170 | 170 | |
171 | 171 | // total accounts from accounts table or ldap |
172 | 172 | $GLOBALS['egw']->accounts->search(array( |
@@ -180,9 +180,9 @@ discard block |
||
180 | 180 | // @ required to get ride of warning, if files are outside of open_basedir |
181 | 181 | if (@file_exists($file = '/etc/SuSE-release') || @file_exists($file = '/etc/redhat-release') || @file_exists($file = '/etc/debian_version')) |
182 | 182 | { |
183 | - $data['os'] .= ': '.str_replace(array("\n","\r"),'',implode(',',file($file))); |
|
183 | + $data['os'] .= ': '.str_replace(array("\n", "\r"), '', implode(',', file($file))); |
|
184 | 184 | } |
185 | - if(file_exists(EGW_INCLUDE_ROOT.'/.git')) |
|
185 | + if (file_exists(EGW_INCLUDE_ROOT.'/.git')) |
|
186 | 186 | { |
187 | 187 | $data['install_type'] = 'git'; |
188 | 188 | } |
@@ -190,22 +190,22 @@ discard block |
||
190 | 190 | { |
191 | 191 | $data['install_type'] = 'svn'; |
192 | 192 | } |
193 | - elseif(EGW_INCLUDE_ROOT == '/usr/share/egroupware' && PHP_OS == 'Linux' && is_link('/usr/share/egroupware/header.inc.php')) |
|
193 | + elseif (EGW_INCLUDE_ROOT == '/usr/share/egroupware' && PHP_OS == 'Linux' && is_link('/usr/share/egroupware/header.inc.php')) |
|
194 | 194 | { |
195 | 195 | $data['install_type'] = 'package'; |
196 | 196 | } |
197 | - foreach(array_keys($GLOBALS['egw_info']['apps']) as $app) |
|
197 | + foreach (array_keys($GLOBALS['egw_info']['apps']) as $app) |
|
198 | 198 | { |
199 | - if (in_array($app,array( |
|
200 | - 'admin','phpgwapi','api','sambaadmin','developer_tools', |
|
201 | - 'home','preferences','etemplate','registration','manual', |
|
199 | + if (in_array($app, array( |
|
200 | + 'admin', 'phpgwapi', 'api', 'sambaadmin', 'developer_tools', |
|
201 | + 'home', 'preferences', 'etemplate', 'registration', 'manual', |
|
202 | 202 | ))) |
203 | 203 | { |
204 | - continue; // --> ignore to not submit too much |
|
204 | + continue; // --> ignore to not submit too much |
|
205 | 205 | } |
206 | 206 | if (($users = self::gather_app_users($app))) // ignore apps noone is allowed to run |
207 | 207 | { |
208 | - $data['apps'][$app] = $app.':'.round(100.0*$users/$data['users']).'%'; |
|
208 | + $data['apps'][$app] = $app.':'.round(100.0 * $users / $data['users']).'%'; |
|
209 | 209 | if (($entries = self::gather_app_entries($app))) |
210 | 210 | { |
211 | 211 | $data['apps'][$app] .= ':'.$entries; |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | } |
214 | 214 | } |
215 | 215 | ksort($data['apps']); |
216 | - $data['apps'] = implode("\n",$data['apps']); |
|
216 | + $data['apps'] = implode("\n", $data['apps']); |
|
217 | 217 | |
218 | 218 | return $data; |
219 | 219 | } |
@@ -227,17 +227,17 @@ discard block |
||
227 | 227 | static function gather_app_users($app) |
228 | 228 | { |
229 | 229 | $users = array(); |
230 | - if (($access = $GLOBALS['egw']->acl->get_ids_for_location('run',1,$app))) |
|
230 | + if (($access = $GLOBALS['egw']->acl->get_ids_for_location('run', 1, $app))) |
|
231 | 231 | { |
232 | - foreach($access as $uid) |
|
232 | + foreach ($access as $uid) |
|
233 | 233 | { |
234 | 234 | if ($uid > 0) |
235 | 235 | { |
236 | 236 | $users[] = $uid; |
237 | 237 | } |
238 | - elseif (($members = $GLOBALS['egw']->accounts->members($uid,true))) |
|
238 | + elseif (($members = $GLOBALS['egw']->accounts->members($uid, true))) |
|
239 | 239 | { |
240 | - $users = array_merge($users,$members); |
|
240 | + $users = array_merge($users, $members); |
|
241 | 241 | } |
242 | 242 | } |
243 | 243 | $users = array_unique($users); |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | 'infolog' => 'egw_infolog', |
262 | 262 | 'filemanager' => 'egw_sqlfs', |
263 | 263 | 'gallery' => 'g2_Item', |
264 | - 'news_admin' => 'egw_news WHERE news_submittedby > 0', // exclude imported rss feeds |
|
264 | + 'news_admin' => 'egw_news WHERE news_submittedby > 0', // exclude imported rss feeds |
|
265 | 265 | 'polls' => 'egw_polls', |
266 | 266 | 'projectmanager' => 'egw_pm_projects', |
267 | 267 | 'phpbrain' => 'egw_kb_articles', |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | $entries = (int)$GLOBALS['egw']->db->query('SELECT COUNT(*) FROM '.$table)->fetchColumn(); |
280 | 280 | //echo "$app ($table): $entries<br />\n"; |
281 | 281 | } |
282 | - catch(Api\Db\Exception $e) { |
|
282 | + catch (Api\Db\Exception $e) { |
|
283 | 283 | unset($e); |
284 | 284 | $entries = null; |
285 | 285 | } |
@@ -293,19 +293,19 @@ discard block |
||
293 | 293 | * @param boolean $redirect should we redirect or return true |
294 | 294 | * @return boolean true if statistic submission is due |
295 | 295 | */ |
296 | - public static function check($redirect=true) |
|
296 | + public static function check($redirect = true) |
|
297 | 297 | { |
298 | 298 | $config = Api\Config::read(self::CONFIG_APP); |
299 | 299 | |
300 | 300 | if (isset($config[self::CONFIG_POSTPONE_SUBMIT]) && $config[self::CONFIG_POSTPONE_SUBMIT] > time() || |
301 | - isset($config[self::CONFIG_LAST_SUBMIT ]) && $config[self::CONFIG_LAST_SUBMIT ] > time()-self::SUBMISION_RATE) |
|
301 | + isset($config[self::CONFIG_LAST_SUBMIT]) && $config[self::CONFIG_LAST_SUBMIT] > time() - self::SUBMISION_RATE) |
|
302 | 302 | { |
303 | 303 | return false; |
304 | 304 | } |
305 | 305 | if (!$redirect) return true; |
306 | 306 | |
307 | 307 | //die('Due for new statistics submission: last_submit='.$config[self::CONFIG_LAST_SUBMIT ].', postpone='.$config[self::CONFIG_POSTPONE_SUBMIT].', '.function_backtrace()); |
308 | - Egw::redirect_link('/index.php',array( |
|
308 | + Egw::redirect_link('/index.php', array( |
|
309 | 309 | 'menuaction' => 'admin.admin_ui.index', |
310 | 310 | 'ajax' => 'true', |
311 | 311 | 'load' => 'admin.admin_statistics.submit', |
@@ -203,9 +203,12 @@ discard block |
||
203 | 203 | { |
204 | 204 | continue; // --> ignore to not submit too much |
205 | 205 | } |
206 | - if (($users = self::gather_app_users($app))) // ignore apps noone is allowed to run |
|
206 | + if (($users = self::gather_app_users($app))) |
|
207 | + { |
|
208 | + // ignore apps noone is allowed to run |
|
207 | 209 | { |
208 | 210 | $data['apps'][$app] = $app.':'.round(100.0*$users/$data['users']).'%'; |
211 | + } |
|
209 | 212 | if (($entries = self::gather_app_entries($app))) |
210 | 213 | { |
211 | 214 | $data['apps'][$app] .= ':'.$entries; |
@@ -302,7 +305,10 @@ discard block |
||
302 | 305 | { |
303 | 306 | return false; |
304 | 307 | } |
305 | - if (!$redirect) return true; |
|
308 | + if (!$redirect) |
|
309 | + { |
|
310 | + return true; |
|
311 | + } |
|
306 | 312 | |
307 | 313 | //die('Due for new statistics submission: last_submit='.$config[self::CONFIG_LAST_SUBMIT ].', postpone='.$config[self::CONFIG_POSTPONE_SUBMIT].', '.function_backtrace()); |
308 | 314 | Egw::redirect_link('/index.php',array( |
@@ -491,6 +491,10 @@ |
||
491 | 491 | protected static function call_hook() |
492 | 492 | { |
493 | 493 | self::$hook_data = array(); |
494 | + |
|
495 | + /** |
|
496 | + * @param string $appname |
|
497 | + */ |
|
494 | 498 | function display_section($appname,$file,$file2=False) |
495 | 499 | { |
496 | 500 | admin_ui::$hook_data[$appname] = $file2 ? $file2 : $file; |
@@ -48,7 +48,10 @@ discard block |
||
48 | 48 | } |
49 | 49 | $tpl = new Etemplate('admin.index'); |
50 | 50 | |
51 | - if (!is_array($content)) $content = array(); |
|
51 | + if (!is_array($content)) |
|
52 | + { |
|
53 | + $content = array(); |
|
54 | + } |
|
52 | 55 | $content['nm'] = array( |
53 | 56 | 'get_rows' => 'admin_ui::get_users', |
54 | 57 | 'no_cat' => true, |
@@ -176,7 +179,10 @@ discard block |
||
176 | 179 | { |
177 | 180 | $GLOBALS['menuData'] = $data = array(); |
178 | 181 | $data = Api\Hooks::single('edit_user', $app); |
179 | - if (!is_array($data)) $data = $GLOBALS['menuData']; |
|
182 | + if (!is_array($data)) |
|
183 | + { |
|
184 | + $data = $GLOBALS['menuData']; |
|
185 | + } |
|
180 | 186 | foreach($data as $item) |
181 | 187 | { |
182 | 188 | // allow hook to return "real" actions, but still support legacy: description, url, extradata, options |
@@ -194,15 +200,30 @@ discard block |
||
194 | 200 | if ($item['options'] && preg_match('/(egw_openWindowCentered2?|window.open)\([^)]+,(\d+),(\d+).*(title="([^"]+)")?/', $item['options'], $matches)) |
195 | 201 | { |
196 | 202 | $item['popup'] = $matches[2].'x'.$matches[3]; |
197 | - if (isset($matches[5])) $item['tooltip'] = $matches[5]; |
|
203 | + if (isset($matches[5])) |
|
204 | + { |
|
205 | + $item['tooltip'] = $matches[5]; |
|
206 | + } |
|
198 | 207 | unset($item['options']); |
199 | 208 | } |
200 | 209 | } |
201 | - if (empty($item['icon'])) $item['icon'] = $app.'/navbar'; |
|
202 | - if (empty($item['group'])) $item['group'] = $group; |
|
203 | - if (empty($item['onExecute'])) $item['onExecute'] = $item['popup'] ? |
|
210 | + if (empty($item['icon'])) |
|
211 | + { |
|
212 | + $item['icon'] = $app.'/navbar'; |
|
213 | + } |
|
214 | + if (empty($item['group'])) |
|
215 | + { |
|
216 | + $item['group'] = $group; |
|
217 | + } |
|
218 | + if (empty($item['onExecute'])) |
|
219 | + { |
|
220 | + $item['onExecute'] = $item['popup'] ? |
|
204 | 221 | 'javaScript:nm_action' : 'javaScript:app.admin.iframe_location'; |
205 | - if (!isset($item['allowOnMultiple'])) $item['allowOnMultiple'] = false; |
|
222 | + } |
|
223 | + if (!isset($item['allowOnMultiple'])) |
|
224 | + { |
|
225 | + $item['allowOnMultiple'] = false; |
|
226 | + } |
|
206 | 227 | |
207 | 228 | $actions[$item['id']] = $item; |
208 | 229 | } |
@@ -248,7 +269,9 @@ discard block |
||
248 | 269 | 'allowOnMultiple' => false |
249 | 270 | ), |
250 | 271 | ); |
251 | - if (!$GLOBALS['egw']->acl->check('account_access',64,'admin')) // no rights to set ACL-rights |
|
272 | + if (!$GLOBALS['egw']->acl->check('account_access',64,'admin')) |
|
273 | + { |
|
274 | + // no rights to set ACL-rights |
|
252 | 275 | { |
253 | 276 | $actions['deny'] = array( |
254 | 277 | 'caption' => 'Deny access', |
@@ -259,6 +282,7 @@ discard block |
||
259 | 282 | 'allowOnMultiple' => false |
260 | 283 | ); |
261 | 284 | } |
285 | + } |
|
262 | 286 | |
263 | 287 | $group = 5; // allow to place actions in different groups by hook, this is the default |
264 | 288 | |
@@ -268,7 +292,10 @@ discard block |
||
268 | 292 | { |
269 | 293 | $GLOBALS['menuData'] = $data = array(); |
270 | 294 | $data = Api\Hooks::single('edit_group', $app); |
271 | - if (!is_array($data)) $data = $GLOBALS['menuData']; |
|
295 | + if (!is_array($data)) |
|
296 | + { |
|
297 | + $data = $GLOBALS['menuData']; |
|
298 | + } |
|
272 | 299 | |
273 | 300 | foreach($data as $item) |
274 | 301 | { |
@@ -288,14 +315,29 @@ discard block |
||
288 | 315 | { |
289 | 316 | $item['popup'] = $matches[2].'x'.$matches[3]; |
290 | 317 | $item['onExecute'] = 'javaScript:nm_action'; |
291 | - if (isset($matches[5])) $item['tooltip'] = $matches[5]; |
|
318 | + if (isset($matches[5])) |
|
319 | + { |
|
320 | + $item['tooltip'] = $matches[5]; |
|
321 | + } |
|
292 | 322 | unset($item['options']); |
293 | 323 | } |
294 | 324 | } |
295 | - if (empty($item['icon'])) $item['icon'] = $app.'/navbar'; |
|
296 | - if (empty($item['group'])) $item['group'] = $group; |
|
297 | - if (empty($item['onExecute'])) $item['onExecute'] = 'javaScript:app.admin.group'; |
|
298 | - if (!isset($item['allowOnMultiple'])) $item['allowOnMultiple'] = false; |
|
325 | + if (empty($item['icon'])) |
|
326 | + { |
|
327 | + $item['icon'] = $app.'/navbar'; |
|
328 | + } |
|
329 | + if (empty($item['group'])) |
|
330 | + { |
|
331 | + $item['group'] = $group; |
|
332 | + } |
|
333 | + if (empty($item['onExecute'])) |
|
334 | + { |
|
335 | + $item['onExecute'] = 'javaScript:app.admin.group'; |
|
336 | + } |
|
337 | + if (!isset($item['allowOnMultiple'])) |
|
338 | + { |
|
339 | + $item['allowOnMultiple'] = false; |
|
340 | + } |
|
299 | 341 | |
300 | 342 | $actions[$item['id']] = $item; |
301 | 343 | } |
@@ -342,7 +384,10 @@ discard block |
||
342 | 384 | ($row['account_expires'] != -1 ? lang('Expires').' '.Api\DateTime::to($row['account_expires'], true) : |
343 | 385 | lang('Enabled'))); |
344 | 386 | |
345 | - if (!self::$accounts->is_active($row)) $row['status_class'] = 'adminAccountInactive'; |
|
387 | + if (!self::$accounts->is_active($row)) |
|
388 | + { |
|
389 | + $row['status_class'] = 'adminAccountInactive'; |
|
390 | + } |
|
346 | 391 | } |
347 | 392 | |
348 | 393 | return self::$accounts->total; |
@@ -439,7 +484,10 @@ discard block |
||
439 | 484 | 'link' => $data, |
440 | 485 | ); |
441 | 486 | } |
442 | - if (empty($data['text'])) $data['text'] = $text; |
|
487 | + if (empty($data['text'])) |
|
488 | + { |
|
489 | + $data['text'] = $text; |
|
490 | + } |
|
443 | 491 | if (empty($data['id'])) |
444 | 492 | { |
445 | 493 | $data['id'] = $root.($app == 'admin' ? 'admin' : 'apps/'.$app).'/'; |
@@ -464,7 +512,11 @@ discard block |
||
464 | 512 | unset($data['icon']); |
465 | 513 | $parent =& $tree['item']; |
466 | 514 | $parts = explode('/', $data['id']); |
467 | - if ($data['id'][0] == '/') array_shift($parts); // remove root |
|
515 | + if ($data['id'][0] == '/') |
|
516 | + { |
|
517 | + array_shift($parts); |
|
518 | + } |
|
519 | + // remove root |
|
468 | 520 | array_pop($parts); |
469 | 521 | $path = ''; |
470 | 522 | foreach($parts as $part) |
@@ -483,14 +535,23 @@ discard block |
||
483 | 535 | 'item' => array(), |
484 | 536 | 'child' => 1, |
485 | 537 | ); |
486 | - if ($path == '/admin') $parent[$path]['open'] = true; |
|
538 | + if ($path == '/admin') |
|
539 | + { |
|
540 | + $parent[$path]['open'] = true; |
|
541 | + } |
|
487 | 542 | } |
488 | 543 | $parent =& $parent[$path]['item']; |
489 | 544 | } |
490 | 545 | $data['text'] = lang($data['text']); |
491 | - if (!empty($data['tooltip'])) $data['tooltip'] = lang($data['tooltip']); |
|
546 | + if (!empty($data['tooltip'])) |
|
547 | + { |
|
548 | + $data['tooltip'] = lang($data['tooltip']); |
|
549 | + } |
|
492 | 550 | // make sure keys are unique, as we overwrite tree entries otherwise |
493 | - if (isset($parent[$data['id']])) $data['id'] .= md5($data['link']); |
|
551 | + if (isset($parent[$data['id']])) |
|
552 | + { |
|
553 | + $data['id'] .= md5($data['link']); |
|
554 | + } |
|
494 | 555 | $parent[$data['id']] = self::fix_userdata($data); |
495 | 556 | } |
496 | 557 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @param array $content |
42 | 42 | */ |
43 | - public function index(array $content=null) |
|
43 | + public function index(array $content = null) |
|
44 | 44 | { |
45 | 45 | if (admin_statistics::check(false)) |
46 | 46 | { |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | //$content['msg'] = 'Hi Ralf ;-)'; |
76 | 76 | $sel_options['tree'] = $this->tree_data(); |
77 | 77 | $sel_options['filter'] = array('' => lang('All groups')); |
78 | - foreach(self::$accounts->search(array( |
|
78 | + foreach (self::$accounts->search(array( |
|
79 | 79 | 'type' => 'groups', |
80 | 80 | 'start' => false, |
81 | 81 | 'order' => 'account_lid', |
@@ -96,13 +96,13 @@ discard block |
||
96 | 96 | // important for first time load eg. from an other application calling it's site configuration |
97 | 97 | $tpl->setElementAttribute('nm', 'disabled', !empty($_GET['load'])); |
98 | 98 | $tpl->setElementAttribute('iframe', 'disabled', empty($_GET['load'])); |
99 | - $content['iframe'] = 'about:blank'; // we show accounts-list be default now |
|
99 | + $content['iframe'] = 'about:blank'; // we show accounts-list be default now |
|
100 | 100 | if (!empty($_GET['load'])) |
101 | 101 | { |
102 | 102 | $vars = $_GET; |
103 | 103 | $vars['menuaction'] = $vars['load']; |
104 | 104 | unset($vars['load']); |
105 | - $content[$vars['ajax'] ? 'ajax_target':'iframe'] = Egw::link('/index.php', $vars); |
|
105 | + $content[$vars['ajax'] ? 'ajax_target' : 'iframe'] = Egw::link('/index.php', $vars); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | $tpl->exec('admin.admin_ui.index', $content, $sel_options); |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | { |
118 | 118 | $actions = static::group_actions(); |
119 | 119 | |
120 | - foreach($actions as $action_id => &$action) |
|
120 | + foreach ($actions as $action_id => &$action) |
|
121 | 121 | { |
122 | 122 | if (!isset($action['enableId']) && !in_array($action_id, array('add'))) |
123 | 123 | { |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | 'default' => true, |
146 | 146 | 'allowOnMultiple' => false, |
147 | 147 | 'onExecute' => 'javaScript:app.admin.account', |
148 | - 'group' => $group=0, |
|
148 | + 'group' => $group = 0, |
|
149 | 149 | ), |
150 | 150 | 'add' => array( |
151 | 151 | 'caption' => 'Add user', |
@@ -156,25 +156,25 @@ discard block |
||
156 | 156 | // generate urls for add/edit accounts via addressbook |
157 | 157 | $edit = Link::get_registry('addressbook', 'edit'); |
158 | 158 | $edit['account_id'] = '$id'; |
159 | - foreach($edit as $name => $val) |
|
159 | + foreach ($edit as $name => $val) |
|
160 | 160 | { |
161 | 161 | $actions['edit']['url'] .= ($actions['edit']['url'] ? '&' : '').$name.'='.$val; |
162 | 162 | } |
163 | 163 | unset($edit['account_id']); |
164 | 164 | $edit['owner'] = 0; |
165 | - foreach($edit as $name => $val) |
|
165 | + foreach ($edit as $name => $val) |
|
166 | 166 | { |
167 | 167 | $actions['add']['url'] .= ($actions['edit']['url'] ? '&' : '').$name.'='.$val; |
168 | 168 | } |
169 | 169 | ++$group; |
170 | 170 | // supporting both old way using $GLOBALS['menuData'] and new just returning data in hook |
171 | 171 | $apps = array_unique(array_merge(array('admin'), Api\Hooks::implemented('edit_user'))); |
172 | - foreach($apps as $app) |
|
172 | + foreach ($apps as $app) |
|
173 | 173 | { |
174 | 174 | $GLOBALS['menuData'] = $data = array(); |
175 | 175 | $data = Api\Hooks::single('edit_user', $app); |
176 | 176 | if (!is_array($data)) $data = $GLOBALS['menuData']; |
177 | - foreach($data as $item) |
|
177 | + foreach ($data as $item) |
|
178 | 178 | { |
179 | 179 | // allow hook to return "real" actions, but still support legacy: description, url, extradata, options |
180 | 180 | if (empty($item['caption'])) |
@@ -229,12 +229,12 @@ discard block |
||
229 | 229 | 'onExecute' => 'javaScript:app.admin.group', |
230 | 230 | 'caption' => 'Show members', |
231 | 231 | 'default' => true, |
232 | - 'group' => $group=1, |
|
232 | + 'group' => $group = 1, |
|
233 | 233 | 'allowOnMultiple' => false |
234 | 234 | ), |
235 | 235 | 'add' => array( |
236 | 236 | 'group' => $group, |
237 | - )+$user_actions['add'], |
|
237 | + ) + $user_actions['add'], |
|
238 | 238 | 'acl' => array( |
239 | 239 | 'onExecute' => 'javaScript:app.admin.group', |
240 | 240 | 'caption' => 'Access control', |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | 'allowOnMultiple' => false |
246 | 246 | ), |
247 | 247 | ); |
248 | - if (!$GLOBALS['egw']->acl->check('account_access',64,'admin')) // no rights to set ACL-rights |
|
248 | + if (!$GLOBALS['egw']->acl->check('account_access', 64, 'admin')) // no rights to set ACL-rights |
|
249 | 249 | { |
250 | 250 | $actions['deny'] = array( |
251 | 251 | 'caption' => 'Deny access', |
@@ -257,17 +257,17 @@ discard block |
||
257 | 257 | ); |
258 | 258 | } |
259 | 259 | |
260 | - $group = 5; // allow to place actions in different groups by hook, this is the default |
|
260 | + $group = 5; // allow to place actions in different groups by hook, this is the default |
|
261 | 261 | |
262 | 262 | // supporting both old way using $GLOBALS['menuData'] and new just returning data in hook |
263 | 263 | $apps = array_unique(array_merge(array('admin'), Api\Hooks::implemented('edit_group'))); |
264 | - foreach($apps as $app) |
|
264 | + foreach ($apps as $app) |
|
265 | 265 | { |
266 | 266 | $GLOBALS['menuData'] = $data = array(); |
267 | 267 | $data = Api\Hooks::single('edit_group', $app); |
268 | 268 | if (!is_array($data)) $data = $GLOBALS['menuData']; |
269 | 269 | |
270 | - foreach($data as $item) |
|
270 | + foreach ($data as $item) |
|
271 | 271 | { |
272 | 272 | // allow hook to return "real" actions, but still support legacy: description, url, extradata, options |
273 | 273 | if (empty($item['caption'])) |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | * @param array &$rows=null |
308 | 308 | * @return int total number of rows available |
309 | 309 | */ |
310 | - public static function get_users(array $query, array &$rows=null) |
|
310 | + public static function get_users(array $query, array &$rows = null) |
|
311 | 311 | { |
312 | 312 | $params = array( |
313 | 313 | 'type' => (int)$query['filter'] ? (int)$query['filter'] : 'accounts', |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | $params['query'] = $query['searchletter']; |
323 | 323 | $params['query_type'] = 'start'; |
324 | 324 | } |
325 | - elseif($query['search']) |
|
325 | + elseif ($query['search']) |
|
326 | 326 | { |
327 | 327 | $params['query'] = $query['search']; |
328 | 328 | $params['query_type'] = 'all'; |
@@ -331,13 +331,10 @@ discard block |
||
331 | 331 | $rows = array_values(self::$accounts->search($params)); |
332 | 332 | //error_log(__METHOD__."() accounts->search(".array2string($params).") total=".self::$accounts->total); |
333 | 333 | |
334 | - foreach($rows as &$row) |
|
334 | + foreach ($rows as &$row) |
|
335 | 335 | { |
336 | 336 | $row['status'] = self::$accounts->is_expired($row) ? |
337 | - lang('Expired').' '.Api\DateTime::to($row['account_expires'], true) : |
|
338 | - (!self::$accounts->is_active($row) ? lang('Disabled') : |
|
339 | - ($row['account_expires'] != -1 ? lang('Expires').' '.Api\DateTime::to($row['account_expires'], true) : |
|
340 | - lang('Enabled'))); |
|
337 | + lang('Expired').' '.Api\DateTime::to($row['account_expires'], true) : (!self::$accounts->is_active($row) ? lang('Disabled') : ($row['account_expires'] != -1 ? lang('Expires').' '.Api\DateTime::to($row['account_expires'], true) : lang('Enabled'))); |
|
341 | 338 | |
342 | 339 | if (!self::$accounts->is_active($row)) $row['status_class'] = 'adminAccountInactive'; |
343 | 340 | } |
@@ -360,29 +357,29 @@ discard block |
||
360 | 357 | )); |
361 | 358 | |
362 | 359 | $apps = array(); |
363 | - foreach($GLOBALS['egw_info']['apps'] as $app => $data) |
|
360 | + foreach ($GLOBALS['egw_info']['apps'] as $app => $data) |
|
364 | 361 | { |
365 | 362 | if (!$data['enabled'] || !$data['status'] || $data['status'] == 3) |
366 | 363 | { |
367 | - continue; // do NOT show disabled apps, or our API (status = 3) |
|
364 | + continue; // do NOT show disabled apps, or our API (status = 3) |
|
368 | 365 | } |
369 | 366 | |
370 | 367 | $apps[] = $app; |
371 | 368 | } |
372 | 369 | |
373 | 370 | $rows = array(); |
374 | - foreach($groups as &$group) |
|
371 | + foreach ($groups as &$group) |
|
375 | 372 | { |
376 | 373 | $run_rights = $GLOBALS['egw']->acl->get_user_applications($group['account_id'], false, false); |
377 | - foreach($apps as $app) |
|
374 | + foreach ($apps as $app) |
|
378 | 375 | { |
379 | - if((boolean)$run_rights[$app]) |
|
376 | + if ((boolean)$run_rights[$app]) |
|
380 | 377 | { |
381 | 378 | $group['apps'][] = $app; |
382 | 379 | } |
383 | 380 | } |
384 | 381 | |
385 | - $group['members'] = $GLOBALS['egw']->accounts->members($group['account_id'],true); |
|
382 | + $group['members'] = $GLOBALS['egw']->accounts->members($group['account_id'], true); |
|
386 | 383 | $rows[] = $group; |
387 | 384 | } |
388 | 385 | |
@@ -422,14 +419,14 @@ discard block |
||
422 | 419 | if ($root == '/') |
423 | 420 | { |
424 | 421 | $hook_data = self::call_hook(); |
425 | - foreach($hook_data as $app => $app_data) |
|
422 | + foreach ($hook_data as $app => $app_data) |
|
426 | 423 | { |
427 | - if(!is_array($app_data)) |
|
424 | + if (!is_array($app_data)) |
|
428 | 425 | { |
429 | 426 | // Application has no data |
430 | 427 | continue; |
431 | 428 | } |
432 | - foreach($app_data as $text => $data) |
|
429 | + foreach ($app_data as $text => $data) |
|
433 | 430 | { |
434 | 431 | if (!is_array($data)) |
435 | 432 | { |
@@ -460,18 +457,17 @@ discard block |
||
460 | 457 | } |
461 | 458 | } |
462 | 459 | unset($data['icon']); |
463 | - $parent =& $tree['item']; |
|
460 | + $parent = & $tree['item']; |
|
464 | 461 | $parts = explode('/', $data['id']); |
465 | - if ($data['id'][0] == '/') array_shift($parts); // remove root |
|
462 | + if ($data['id'][0] == '/') array_shift($parts); // remove root |
|
466 | 463 | array_pop($parts); |
467 | 464 | $path = ''; |
468 | - foreach($parts as $part) |
|
465 | + foreach ($parts as $part) |
|
469 | 466 | { |
470 | 467 | $path .= ($path == '/' ? '' : '/').$part; |
471 | 468 | if (!isset($parent[$path])) |
472 | 469 | { |
473 | - $icon = Etemplate\Widget\Tree::imagePath($part == 'apps' ? Api\Image::find('api', 'home') : |
|
474 | - (($i=Api\Image::find($part, 'navbar')) ? $i : Api\Image::find('api', 'nonav'))); |
|
470 | + $icon = Etemplate\Widget\Tree::imagePath($part == 'apps' ? Api\Image::find('api', 'home') : (($i = Api\Image::find($part, 'navbar')) ? $i : Api\Image::find('api', 'nonav'))); |
|
475 | 471 | $parent[$path] = array( |
476 | 472 | 'id' => $path, |
477 | 473 | 'text' => $part == 'apps' ? lang('Applications') : lang($part), |
@@ -483,7 +479,7 @@ discard block |
||
483 | 479 | ); |
484 | 480 | if ($path == '/admin') $parent[$path]['open'] = true; |
485 | 481 | } |
486 | - $parent =& $parent[$path]['item']; |
|
482 | + $parent = & $parent[$path]['item']; |
|
487 | 483 | } |
488 | 484 | $data['text'] = lang($data['text']); |
489 | 485 | if (!empty($data['tooltip'])) $data['tooltip'] = lang($data['tooltip']); |
@@ -495,7 +491,7 @@ discard block |
||
495 | 491 | } |
496 | 492 | elseif ($root == '/groups') |
497 | 493 | { |
498 | - foreach($GLOBALS['egw']->accounts->search(array( |
|
494 | + foreach ($GLOBALS['egw']->accounts->search(array( |
|
499 | 495 | 'type' => 'groups', |
500 | 496 | 'order' => 'account_lid', |
501 | 497 | 'sort' => 'ASC', |
@@ -522,8 +518,8 @@ discard block |
||
522 | 518 | private static function fix_userdata(array $data) |
523 | 519 | { |
524 | 520 | // store link as userdata, maybe we should store everything not directly understood by tree this way ... |
525 | - foreach(array_diff_key($data, array_flip(array( |
|
526 | - 'id','text','tooltip','im0','im1','im2','item','child','select','open','call', |
|
521 | + foreach (array_diff_key($data, array_flip(array( |
|
522 | + 'id', 'text', 'tooltip', 'im0', 'im1', 'im2', 'item', 'child', 'select', 'open', 'call', |
|
527 | 523 | ))) as $name => $content) |
528 | 524 | { |
529 | 525 | $data['userdata'][] = array( |
@@ -543,7 +539,7 @@ discard block |
||
543 | 539 | private static function strip_item_keys(array &$items) |
544 | 540 | { |
545 | 541 | $items = array_values($items); |
546 | - foreach($items as &$item) |
|
542 | + foreach ($items as &$item) |
|
547 | 543 | { |
548 | 544 | if (is_array($item) && isset($item['item'])) |
549 | 545 | { |
@@ -561,7 +557,7 @@ discard block |
||
561 | 557 | protected static function call_hook() |
562 | 558 | { |
563 | 559 | self::$hook_data = array(); |
564 | - function display_section($appname,$file,$file2=False) |
|
560 | + function display_section($appname, $file, $file2 = False) |
|
565 | 561 | { |
566 | 562 | admin_ui::$hook_data[$appname] = $file2 ? $file2 : $file; |
567 | 563 | //error_log(__METHOD__."(".array2string(func_get_args()).")"); |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | * Delete ACL record in the repository of the class |
167 | 167 | * |
168 | 168 | * @param string $appname appname or '' for $GLOBALS['egw_info']['flags']['currentapp'] |
169 | - * @param string/boolean $location location or false for all locations |
|
169 | + * @param boolean $location location or false for all locations |
|
170 | 170 | * @return array all ACL records from $this->data. |
171 | 171 | */ |
172 | 172 | function delete($appname,$location) |
@@ -267,8 +267,8 @@ discard block |
||
267 | 267 | /** |
268 | 268 | * check required rights agains the internal repository (included rights of $this->account_id and all it's memberships) |
269 | 269 | * |
270 | - * @param $location app location |
|
271 | - * @param $required required right to check against |
|
270 | + * @param string $location app location |
|
271 | + * @param integer $required required right to check against |
|
272 | 272 | * @param $appname optional defaults to currentapp |
273 | 273 | * @return boolean |
274 | 274 | */ |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | /** |
33 | 33 | * @var array $data internal repository with acl rows for the given app and account-id (incl. memberships) |
34 | 34 | */ |
35 | - var $data = Array(); |
|
35 | + var $data = array(); |
|
36 | 36 | /** |
37 | 37 | * internal reference to global db-object |
38 | 38 | * |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | array_unshift($acl_acc_list,$this->account_id); |
134 | 134 | } |
135 | 135 | |
136 | - $this->data = Array(); |
|
136 | + $this->data = array(); |
|
137 | 137 | foreach($this->db->select(self::TABLE,'*',array('acl_account' => $acl_acc_list ),__LINE__,__FILE__) as $row) |
138 | 138 | { |
139 | 139 | $this->data[$row['acl_appname'].'-'.$row['acl_location'].'-'.$row['acl_account']] = Db::strip_array_keys($row,'acl_'); |
@@ -676,7 +676,7 @@ discard block |
||
676 | 676 | if ((int)$user > 0) $memberships = $GLOBALS['egw']->accounts->memberships($user, true); |
677 | 677 | $memberships[] = $user; |
678 | 678 | |
679 | - $grants = $accounts = Array(); |
|
679 | + $grants = $accounts = array(); |
|
680 | 680 | foreach($this->db->select(self::TABLE,array('acl_account','acl_rights','acl_location'),array( |
681 | 681 | 'acl_appname' => $app, |
682 | 682 | 'acl_location' => $memberships, |
@@ -47,15 +47,15 @@ discard block |
||
47 | 47 | /** |
48 | 48 | * Constants for acl rights, like old EGW_ACL_* defines |
49 | 49 | */ |
50 | - const READ = 1; // EGW_ACL_READ |
|
51 | - const ADD = 2; // EGW_ACL_ADD |
|
52 | - const EDIT = 4; // EGW_ACL_EDIT |
|
53 | - const DELETE = 8; // EGW_ACL_DELETE |
|
54 | - const PRIVAT = 16; // EGW_ACL_PRIVATE can NOT use PRIVATE as it is a PHP keyword, using German PRIVAT instead! |
|
55 | - const GROUPMGRS = 32; // EGW_ACL_GROUP_MANAGERS |
|
56 | - const CUSTOM1 = 64; // EGW_ACL_CUSTOM_1 |
|
57 | - const CUSTOM2 = 128; // EGW_ACL_CUSTOM_2 |
|
58 | - const CUSTOM3 = 256; // EGW_ACL_CUSTOM_3 |
|
50 | + const READ = 1; // EGW_ACL_READ |
|
51 | + const ADD = 2; // EGW_ACL_ADD |
|
52 | + const EDIT = 4; // EGW_ACL_EDIT |
|
53 | + const DELETE = 8; // EGW_ACL_DELETE |
|
54 | + const PRIVAT = 16; // EGW_ACL_PRIVATE can NOT use PRIVATE as it is a PHP keyword, using German PRIVAT instead! |
|
55 | + const GROUPMGRS = 32; // EGW_ACL_GROUP_MANAGERS |
|
56 | + const CUSTOM1 = 64; // EGW_ACL_CUSTOM_1 |
|
57 | + const CUSTOM2 = 128; // EGW_ACL_CUSTOM_2 |
|
58 | + const CUSTOM3 = 256; // EGW_ACL_CUSTOM_3 |
|
59 | 59 | |
60 | 60 | /** |
61 | 61 | * ACL constructor for setting account id |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | } |
79 | 79 | if ((int)$this->account_id != (int)$account_id) |
80 | 80 | { |
81 | - $this->account_id = get_account_id((int)$account_id,@$GLOBALS['egw_info']['user']['account_id']); |
|
81 | + $this->account_id = get_account_id((int)$account_id, @$GLOBALS['egw_info']['user']['account_id']); |
|
82 | 82 | } |
83 | 83 | $this->data = array(); |
84 | 84 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | */ |
92 | 92 | function __sleep() |
93 | 93 | { |
94 | - return array('account_id','db'); |
|
94 | + return array('account_id', 'db'); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /**************************************************************************\ |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * @param boolean|array $no_groups = false if true, do not use memberships, if array do not use given groups |
105 | 105 | * @return array along with storing it in $acl->data. <br> |
106 | 106 | */ |
107 | - function read_repository($no_groups=false) |
|
107 | + function read_repository($no_groups = false) |
|
108 | 108 | { |
109 | 109 | // For some reason, calling this via XML-RPC doesn't call the constructor. |
110 | 110 | // Here is yet another work around(tm) (jengo) |
@@ -119,14 +119,14 @@ discard block |
||
119 | 119 | else |
120 | 120 | { |
121 | 121 | $acl_acc_list = (array)$GLOBALS['egw']->accounts->memberships($this->account_id, true); |
122 | - if (is_array($no_groups)) $acl_acc_list = array_diff($acl_acc_list,$no_groups); |
|
123 | - array_unshift($acl_acc_list,$this->account_id); |
|
122 | + if (is_array($no_groups)) $acl_acc_list = array_diff($acl_acc_list, $no_groups); |
|
123 | + array_unshift($acl_acc_list, $this->account_id); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | $this->data = Array(); |
127 | - foreach($this->db->select(self::TABLE,'*',array('acl_account' => $acl_acc_list ),__LINE__,__FILE__) as $row) |
|
127 | + foreach ($this->db->select(self::TABLE, '*', array('acl_account' => $acl_acc_list), __LINE__, __FILE__) as $row) |
|
128 | 128 | { |
129 | - $this->data[$row['acl_appname'].'-'.$row['acl_location'].'-'.$row['acl_account']] = Db::strip_array_keys($row,'acl_'); |
|
129 | + $this->data[$row['acl_appname'].'-'.$row['acl_location'].'-'.$row['acl_account']] = Db::strip_array_keys($row, 'acl_'); |
|
130 | 130 | } |
131 | 131 | return $this->data; |
132 | 132 | } |
@@ -155,15 +155,15 @@ discard block |
||
155 | 155 | * @param int $rights rights |
156 | 156 | * @return array all ACL records from $this->data. |
157 | 157 | */ |
158 | - function add($appname,$location,$rights) |
|
158 | + function add($appname, $location, $rights) |
|
159 | 159 | { |
160 | 160 | if (!$appname) $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
161 | 161 | |
162 | 162 | $row = array( |
163 | 163 | 'appname' => $appname, |
164 | 164 | 'location' => $location, |
165 | - 'account' => (int) $this->account_id, |
|
166 | - 'rights' => (int) $rights |
|
165 | + 'account' => (int)$this->account_id, |
|
166 | + 'rights' => (int)$rights |
|
167 | 167 | ); |
168 | 168 | $this->data[$row['appname'].'-'.$row['location'].'-'.$row['account']] = $row; |
169 | 169 | |
@@ -177,11 +177,11 @@ discard block |
||
177 | 177 | * @param string/boolean $location location or false for all locations |
178 | 178 | * @return array all ACL records from $this->data. |
179 | 179 | */ |
180 | - function delete($appname,$location) |
|
180 | + function delete($appname, $location) |
|
181 | 181 | { |
182 | 182 | if (!$appname) $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
183 | 183 | |
184 | - foreach($this->data as $idx => $value) |
|
184 | + foreach ($this->data as $idx => $value) |
|
185 | 185 | { |
186 | 186 | if ($value['appname'] == $appname && |
187 | 187 | ($location === false || $value['location'] == $location) && |
@@ -200,24 +200,24 @@ discard block |
||
200 | 200 | */ |
201 | 201 | function save_repository() |
202 | 202 | { |
203 | - $this->db->delete(self::TABLE,array( |
|
203 | + $this->db->delete(self::TABLE, array( |
|
204 | 204 | 'acl_account' => $this->account_id, |
205 | - ),__LINE__,__FILE__); |
|
205 | + ), __LINE__, __FILE__); |
|
206 | 206 | |
207 | - foreach($this->data as $value) |
|
207 | + foreach ($this->data as $value) |
|
208 | 208 | { |
209 | 209 | if ($value['account'] == $this->account_id) |
210 | 210 | { |
211 | - $this->db->insert(self::TABLE,array( |
|
211 | + $this->db->insert(self::TABLE, array( |
|
212 | 212 | 'acl_appname' => $value['appname'], |
213 | 213 | 'acl_location' => $value['location'], |
214 | 214 | 'acl_account' => $this->account_id, |
215 | 215 | 'acl_rights' => $value['rights'], |
216 | - ),false,__LINE__,__FILE__); |
|
216 | + ), false, __LINE__, __FILE__); |
|
217 | 217 | } |
218 | 218 | } |
219 | 219 | if ($this->account_id == $GLOBALS['egw_info']['user']['account_id'] && |
220 | - method_exists($GLOBALS['egw'],'invalidate_session_cache')) // egw object in setup is limited |
|
220 | + method_exists($GLOBALS['egw'], 'invalidate_session_cache')) // egw object in setup is limited |
|
221 | 221 | { |
222 | 222 | $GLOBALS['egw']->invalidate_session_cache(); |
223 | 223 | } |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | * @param string $appname optional defaults to $GLOBALS['egw_info']['flags']['currentapp']; |
236 | 236 | * @return int all rights or'ed together |
237 | 237 | */ |
238 | - function get_rights($location,$appname = '') |
|
238 | + function get_rights($location, $appname = '') |
|
239 | 239 | { |
240 | 240 | // For XML-RPC, change this once its working correctly for passing parameters (jengo) |
241 | 241 | if (is_array($location)) |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | return True; |
256 | 256 | } |
257 | 257 | $rights = 0; |
258 | - foreach($this->data as $value) |
|
258 | + foreach ($this->data as $value) |
|
259 | 259 | { |
260 | 260 | if ($value['appname'] == $appname) |
261 | 261 | { |
@@ -282,9 +282,9 @@ discard block |
||
282 | 282 | */ |
283 | 283 | function check($location, $required, $appname = False) |
284 | 284 | { |
285 | - $rights = $this->get_rights($location,$appname); |
|
285 | + $rights = $this->get_rights($location, $appname); |
|
286 | 286 | |
287 | - return !!($rights & $required); |
|
287 | + return !!($rights&$required); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | /** |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | * @param array $memberships = array() additional account_id, eg. memberships to match beside $this->account_id, default none |
296 | 296 | * @return int $rights |
297 | 297 | */ |
298 | - function get_specific_rights($location, $appname = '', $memberships=array()) |
|
298 | + function get_specific_rights($location, $appname = '', $memberships = array()) |
|
299 | 299 | { |
300 | 300 | if (!$appname) $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
301 | 301 | |
@@ -305,10 +305,10 @@ discard block |
||
305 | 305 | } |
306 | 306 | $rights = 0; |
307 | 307 | |
308 | - foreach($this->data as $value) |
|
308 | + foreach ($this->data as $value) |
|
309 | 309 | { |
310 | 310 | if ($value['appname'] == $appname && |
311 | - ($value['location'] == $location || $value['location'] == 'everywhere') && |
|
311 | + ($value['location'] == $location || $value['location'] == 'everywhere') && |
|
312 | 312 | ($value['account'] == $this->account_id || $memberships && in_array($value['account'], $memberships))) |
313 | 313 | { |
314 | 314 | if ($value['rights'] == 0) |
@@ -331,9 +331,9 @@ discard block |
||
331 | 331 | */ |
332 | 332 | function check_specific($location, $required, $appname = '') |
333 | 333 | { |
334 | - $rights = $this->get_specific_rights($location,$appname); |
|
334 | + $rights = $this->get_specific_rights($location, $appname); |
|
335 | 335 | |
336 | - return !!($rights & $required); |
|
336 | + return !!($rights&$required); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | /**************************************************************************\ |
@@ -350,19 +350,19 @@ discard block |
||
350 | 350 | * @param boolean $invalidate_session =true false: do NOT invalidate session |
351 | 351 | * @return int number of affected rows: 0: no change, 1: acl changed |
352 | 352 | */ |
353 | - function add_repository($app, $location, $account_id, $rights, $invalidate_session=true) |
|
353 | + function add_repository($app, $location, $account_id, $rights, $invalidate_session = true) |
|
354 | 354 | { |
355 | 355 | //echo "<p>self::add_repository('$app','$location',$account_id,$rights);</p>\n"; |
356 | - $this->db->insert(self::TABLE,array( |
|
356 | + $this->db->insert(self::TABLE, array( |
|
357 | 357 | 'acl_rights' => $rights, |
358 | - ),array( |
|
358 | + ), array( |
|
359 | 359 | 'acl_appname' => $app, |
360 | 360 | 'acl_location' => $location, |
361 | 361 | 'acl_account' => $account_id, |
362 | - ),__LINE__,__FILE__); |
|
362 | + ), __LINE__, __FILE__); |
|
363 | 363 | |
364 | 364 | if ($invalidate_session && $account_id == $GLOBALS['egw_info']['user']['account_id'] && |
365 | - method_exists($GLOBALS['egw'],'invalidate_session_cache')) // egw object in setup is limited |
|
365 | + method_exists($GLOBALS['egw'], 'invalidate_session_cache')) // egw object in setup is limited |
|
366 | 366 | { |
367 | 367 | $GLOBALS['egw']->invalidate_session_cache(); |
368 | 368 | } |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | * @param boolean $invalidate_session =true false: do NOT invalidate session |
379 | 379 | * @return int number of rows deleted |
380 | 380 | */ |
381 | - function delete_repository($app, $location, $accountid='', $invalidate_session=true) |
|
381 | + function delete_repository($app, $location, $accountid = '', $invalidate_session = true) |
|
382 | 382 | { |
383 | 383 | static $cache_accountid = array(); |
384 | 384 | |
@@ -388,22 +388,22 @@ discard block |
||
388 | 388 | ); |
389 | 389 | if ($accountid !== false) |
390 | 390 | { |
391 | - if(isset($cache_accountid[$accountid]) && $cache_accountid[$accountid]) |
|
391 | + if (isset($cache_accountid[$accountid]) && $cache_accountid[$accountid]) |
|
392 | 392 | { |
393 | 393 | $where['acl_account'] = $cache_accountid[$accountid]; |
394 | 394 | } |
395 | 395 | else |
396 | 396 | { |
397 | - $where['acl_account'] = $cache_accountid[$accountid] = get_account_id($accountid,$this->account_id); |
|
397 | + $where['acl_account'] = $cache_accountid[$accountid] = get_account_id($accountid, $this->account_id); |
|
398 | 398 | } |
399 | 399 | } |
400 | 400 | if ($app == '%' || $app == '%%') unset($where['acl_appname']); |
401 | 401 | |
402 | - $this->db->delete(self::TABLE,$where,__LINE__,__FILE__); |
|
402 | + $this->db->delete(self::TABLE, $where, __LINE__, __FILE__); |
|
403 | 403 | |
404 | 404 | $deleted = $this->db->affected_rows(); |
405 | 405 | |
406 | - if ($invalidate_session && $deleted && method_exists($GLOBALS['egw'],'invalidate_session_cache')) // egw object in setup is limited |
|
406 | + if ($invalidate_session && $deleted && method_exists($GLOBALS['egw'], 'invalidate_session_cache')) // egw object in setup is limited |
|
407 | 407 | { |
408 | 408 | $GLOBALS['egw']->invalidate_session_cache(); |
409 | 409 | } |
@@ -418,15 +418,15 @@ discard block |
||
418 | 418 | * @param string $appname = '' defaults to current app |
419 | 419 | * @return int/boolean rights or false if none exist |
420 | 420 | */ |
421 | - function get_specific_rights_for_account($account_id,$location,$appname='') |
|
421 | + function get_specific_rights_for_account($account_id, $location, $appname = '') |
|
422 | 422 | { |
423 | 423 | if (!$appname) $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
424 | 424 | |
425 | - return $this->db->select(self::TABLE,'acl_rights',array( |
|
425 | + return $this->db->select(self::TABLE, 'acl_rights', array( |
|
426 | 426 | 'acl_location' => $location, |
427 | 427 | 'acl_account' => $account_id, |
428 | 428 | 'acl_appname' => $appname, |
429 | - ),__LINE__,__FILE__)->fetchColumn(); |
|
429 | + ), __LINE__, __FILE__)->fetchColumn(); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | /** |
@@ -436,15 +436,15 @@ discard block |
||
436 | 436 | * @param string $appname = '' defaults to current app |
437 | 437 | * @return array with account => rights pairs |
438 | 438 | */ |
439 | - function get_all_rights($location,$appname='') |
|
439 | + function get_all_rights($location, $appname = '') |
|
440 | 440 | { |
441 | 441 | if (!$appname) $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
442 | 442 | |
443 | 443 | $rights = array(); |
444 | - foreach($this->db->select(self::TABLE,'acl_account,acl_rights',array( |
|
444 | + foreach ($this->db->select(self::TABLE, 'acl_account,acl_rights', array( |
|
445 | 445 | 'acl_location' => $location, |
446 | 446 | 'acl_appname' => $appname, |
447 | - ),__LINE__,__FILE__) as $row) |
|
447 | + ), __LINE__, __FILE__) as $row) |
|
448 | 448 | { |
449 | 449 | $rights[$row['acl_account']] = $row['acl_rights']; |
450 | 450 | } |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | * @param boolean $use_memberships = true |
460 | 460 | * @return array with location => rights pairs |
461 | 461 | */ |
462 | - function get_all_location_rights($account_id,$appname='',$use_memberships=true) |
|
462 | + function get_all_location_rights($account_id, $appname = '', $use_memberships = true) |
|
463 | 463 | { |
464 | 464 | if (!$appname) $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
465 | 465 | |
@@ -470,10 +470,10 @@ discard block |
||
470 | 470 | $accounts[] = $account_id; |
471 | 471 | } |
472 | 472 | $rights = array(); |
473 | - foreach($this->db->select(self::TABLE,'acl_location,acl_rights',array( |
|
473 | + foreach ($this->db->select(self::TABLE, 'acl_location,acl_rights', array( |
|
474 | 474 | 'acl_account' => $accounts, |
475 | 475 | 'acl_appname' => $appname, |
476 | - ),__LINE__,__FILE__) as $row) |
|
476 | + ), __LINE__, __FILE__) as $row) |
|
477 | 477 | { |
478 | 478 | $rights[$row['acl_location']] |= $row['acl_rights']; |
479 | 479 | } |
@@ -492,28 +492,28 @@ discard block |
||
492 | 492 | { |
493 | 493 | static $cache_accountid = array(); |
494 | 494 | |
495 | - if(isset($cache_accountid[$accountid])) |
|
495 | + if (isset($cache_accountid[$accountid])) |
|
496 | 496 | { |
497 | 497 | $account_id = $cache_accountid[$accountid]; |
498 | 498 | } |
499 | 499 | else |
500 | 500 | { |
501 | - $account_id = get_account_id($accountid,$this->account_id); |
|
501 | + $account_id = get_account_id($accountid, $this->account_id); |
|
502 | 502 | $cache_accountid[$accountid] = $account_id; |
503 | 503 | } |
504 | 504 | $rights = 0; |
505 | 505 | $apps = false; |
506 | - foreach($this->db->select(self::TABLE,array('acl_appname','acl_rights'),array( |
|
506 | + foreach ($this->db->select(self::TABLE, array('acl_appname', 'acl_rights'), array( |
|
507 | 507 | 'acl_location' => $location, |
508 | 508 | 'acl_account' => $account_id, |
509 | - ),__LINE__,__FILE__) as $row) |
|
509 | + ), __LINE__, __FILE__) as $row) |
|
510 | 510 | { |
511 | 511 | if ($row['acl_rights'] == 0) |
512 | 512 | { |
513 | 513 | return False; |
514 | 514 | } |
515 | 515 | $rights |= $row['acl_rights']; |
516 | - if (!!($rights & $required)) |
|
516 | + if (!!($rights&$required)) |
|
517 | 517 | { |
518 | 518 | $apps[] = $row['acl_appname']; |
519 | 519 | } |
@@ -533,21 +533,21 @@ discard block |
||
533 | 533 | { |
534 | 534 | static $cache_accountid = array(); |
535 | 535 | |
536 | - if(isset($cache_accountid[$accountid])) |
|
536 | + if (isset($cache_accountid[$accountid])) |
|
537 | 537 | { |
538 | 538 | $accountid = $cache_accountid[$accountid]; |
539 | 539 | } |
540 | 540 | else |
541 | 541 | { |
542 | - $accountid = $cache_accountid[$accountid] = get_account_id($accountid,$this->account_id); |
|
542 | + $accountid = $cache_accountid[$accountid] = get_account_id($accountid, $this->account_id); |
|
543 | 543 | } |
544 | 544 | $locations = false; |
545 | - foreach($this->db->select(self::TABLE,'acl_location,acl_rights',array( |
|
545 | + foreach ($this->db->select(self::TABLE, 'acl_location,acl_rights', array( |
|
546 | 546 | 'acl_appname' => $app, |
547 | 547 | 'acl_account' => $accountid, |
548 | - ),__LINE__,__FILE__) as $row) |
|
548 | + ), __LINE__, __FILE__) as $row) |
|
549 | 549 | { |
550 | - if ($row['acl_rights'] & $required) |
|
550 | + if ($row['acl_rights']&$required) |
|
551 | 551 | { |
552 | 552 | $locations[] = $row['acl_location']; |
553 | 553 | } |
@@ -568,14 +568,14 @@ discard block |
||
568 | 568 | if (!$app) $app = $GLOBALS['egw_info']['flags']['currentapp']; |
569 | 569 | |
570 | 570 | $accounts = false; |
571 | - foreach($this->db->select(self::TABLE,array('acl_account','acl_rights'),array( |
|
571 | + foreach ($this->db->select(self::TABLE, array('acl_account', 'acl_rights'), array( |
|
572 | 572 | 'acl_appname' => $app, |
573 | 573 | 'acl_location' => $location, |
574 | - ),__LINE__,__FILE__) as $row) |
|
574 | + ), __LINE__, __FILE__) as $row) |
|
575 | 575 | { |
576 | - if (!!($row['acl_rights'] & $required)) |
|
576 | + if (!!($row['acl_rights']&$required)) |
|
577 | 577 | { |
578 | - $accounts[] = (int) $row['acl_account']; |
|
578 | + $accounts[] = (int)$row['acl_account']; |
|
579 | 579 | } |
580 | 580 | } |
581 | 581 | return $accounts; |
@@ -587,14 +587,14 @@ discard block |
||
587 | 587 | * @param string $app app optional defaults to $GLOBALS['egw_info']['flags']['currentapp']; |
588 | 588 | * @return boolean/array false if there are no matching location in the db or array of locations |
589 | 589 | */ |
590 | - function get_locations_for_app($app='') |
|
590 | + function get_locations_for_app($app = '') |
|
591 | 591 | { |
592 | 592 | if (!$app) $app = $GLOBALS['egw_info']['flags']['currentapp']; |
593 | 593 | |
594 | 594 | $locations = false; |
595 | - foreach($this->db->select(self::TABLE,'DISTINCT '.'acl_location',array( |
|
595 | + foreach ($this->db->select(self::TABLE, 'DISTINCT '.'acl_location', array( |
|
596 | 596 | 'acl_appname' => $app, |
597 | - ),__LINE__,__FILE__) as $row) |
|
597 | + ), __LINE__, __FILE__) as $row) |
|
598 | 598 | { |
599 | 599 | if (($location = $row['acl_location']) != 'run') |
600 | 600 | { |
@@ -612,38 +612,38 @@ discard block |
||
612 | 612 | * @param boolean $add_implicit_apps = true true: add apps every user has implicit rights |
613 | 613 | * @return array containing list of apps |
614 | 614 | */ |
615 | - function get_user_applications($accountid = '', $use_memberships=true, $add_implicit_apps=true) |
|
615 | + function get_user_applications($accountid = '', $use_memberships = true, $add_implicit_apps = true) |
|
616 | 616 | { |
617 | 617 | static $cache_accountid = array(); |
618 | 618 | |
619 | - if(isset($cache_accountid[$accountid])) |
|
619 | + if (isset($cache_accountid[$accountid])) |
|
620 | 620 | { |
621 | 621 | $account_id = $cache_accountid[$accountid]; |
622 | 622 | } |
623 | 623 | else |
624 | 624 | { |
625 | - $account_id = get_account_id($accountid,$this->account_id); |
|
625 | + $account_id = get_account_id($accountid, $this->account_id); |
|
626 | 626 | $cache_accountid[$accountid] = $account_id; |
627 | 627 | } |
628 | 628 | if ($use_memberships && (int)$account_id > 0) $memberships = $GLOBALS['egw']->accounts->memberships($account_id, true); |
629 | 629 | $memberships[] = (int)$account_id; |
630 | 630 | |
631 | 631 | $apps = array(); |
632 | - foreach($this->db->select(self::TABLE,array('acl_appname','acl_rights'),array( |
|
632 | + foreach ($this->db->select(self::TABLE, array('acl_appname', 'acl_rights'), array( |
|
633 | 633 | 'acl_location' => 'run', |
634 | 634 | 'acl_account' => $memberships, |
635 | - ),__LINE__,__FILE__) as $row) |
|
635 | + ), __LINE__, __FILE__) as $row) |
|
636 | 636 | { |
637 | 637 | $app = $row['acl_appname']; |
638 | - if(!isset($apps[$app])) |
|
638 | + if (!isset($apps[$app])) |
|
639 | 639 | { |
640 | 640 | $apps[$app] = 0; |
641 | 641 | } |
642 | - $apps[$app] |= (int) $row['acl_rights']; |
|
642 | + $apps[$app] |= (int)$row['acl_rights']; |
|
643 | 643 | } |
644 | 644 | if ($add_implicit_apps) |
645 | 645 | { |
646 | - $apps['api'] = 1; // give everyone implicit rights for the home app |
|
646 | + $apps['api'] = 1; // give everyone implicit rights for the home app |
|
647 | 647 | } |
648 | 648 | return $apps; |
649 | 649 | } |
@@ -657,29 +657,29 @@ discard block |
||
657 | 657 | * @param int $user = null user whos grants to return, default current user |
658 | 658 | * @return array with account-ids (of owners) and granted rights as values |
659 | 659 | */ |
660 | - function get_grants($app='',$enum_group_acls=true,$user=null) |
|
660 | + function get_grants($app = '', $enum_group_acls = true, $user = null) |
|
661 | 661 | { |
662 | 662 | if (!$app) $app = $GLOBALS['egw_info']['flags']['currentapp']; |
663 | 663 | if (!$user) $user = $this->account_id; |
664 | 664 | |
665 | - static $cache = array(); // some caching withing the request |
|
665 | + static $cache = array(); // some caching withing the request |
|
666 | 666 | |
667 | - $grants =& $cache[$app][$user]; |
|
667 | + $grants = & $cache[$app][$user]; |
|
668 | 668 | if (!isset($grants)) |
669 | 669 | { |
670 | 670 | if ((int)$user > 0) $memberships = $GLOBALS['egw']->accounts->memberships($user, true); |
671 | 671 | $memberships[] = $user; |
672 | 672 | |
673 | 673 | $grants = $accounts = Array(); |
674 | - foreach($this->db->select(self::TABLE,array('acl_account','acl_rights','acl_location'),array( |
|
674 | + foreach ($this->db->select(self::TABLE, array('acl_account', 'acl_rights', 'acl_location'), array( |
|
675 | 675 | 'acl_appname' => $app, |
676 | 676 | 'acl_location' => $memberships, |
677 | - ),__LINE__,__FILE__) as $row) |
|
677 | + ), __LINE__, __FILE__) as $row) |
|
678 | 678 | { |
679 | 679 | $grantor = $row['acl_account']; |
680 | 680 | $rights = $row['acl_rights']; |
681 | 681 | |
682 | - if(!isset($grants[$grantor])) |
|
682 | + if (!isset($grants[$grantor])) |
|
683 | 683 | { |
684 | 684 | $grants[$grantor] = 0; |
685 | 685 | } |
@@ -687,17 +687,17 @@ discard block |
||
687 | 687 | |
688 | 688 | // if the right is granted from a group and we enummerated group ACL's |
689 | 689 | if ($GLOBALS['egw']->accounts->get_type($grantor) == 'g' && $enum_group_acls && |
690 | - (!is_array($enum_group_acls) || !in_array($grantor,$enum_group_acls))) |
|
690 | + (!is_array($enum_group_acls) || !in_array($grantor, $enum_group_acls))) |
|
691 | 691 | { |
692 | 692 | // return the grant for each member of the group (false = also for no longer active users) |
693 | - foreach((array)$GLOBALS['egw']->accounts->members($grantor, true, false) as $grantor) |
|
693 | + foreach ((array)$GLOBALS['egw']->accounts->members($grantor, true, false) as $grantor) |
|
694 | 694 | { |
695 | - if (!$grantor) continue; // can happen if group has no members |
|
695 | + if (!$grantor) continue; // can happen if group has no members |
|
696 | 696 | |
697 | 697 | // Don't allow to override private with group ACL's! |
698 | 698 | $rights &= ~self::PRIVAT; |
699 | 699 | |
700 | - if(!isset($grants[$grantor])) |
|
700 | + if (!isset($grants[$grantor])) |
|
701 | 701 | { |
702 | 702 | $grants[$grantor] = 0; |
703 | 703 | } |
@@ -719,21 +719,21 @@ discard block |
||
719 | 719 | */ |
720 | 720 | function delete_account($account_id) |
721 | 721 | { |
722 | - if ((int) $account_id) |
|
722 | + if ((int)$account_id) |
|
723 | 723 | { |
724 | 724 | // Delete all grants from this account |
725 | - $this->db->delete(self::TABLE,array( |
|
725 | + $this->db->delete(self::TABLE, array( |
|
726 | 726 | 'acl_account' => $account_id |
727 | - ),__LINE__,__FILE__); |
|
727 | + ), __LINE__, __FILE__); |
|
728 | 728 | // Delete all grants to this account |
729 | - $this->db->delete(self::TABLE,array( |
|
729 | + $this->db->delete(self::TABLE, array( |
|
730 | 730 | 'acl_location' => $account_id |
731 | - ),__LINE__, __FILE__); |
|
731 | + ), __LINE__, __FILE__); |
|
732 | 732 | // delete all memberships in account_id (if it is a group) |
733 | - $this->db->delete(self::TABLE,array( |
|
733 | + $this->db->delete(self::TABLE, array( |
|
734 | 734 | 'acl_appname' => 'phpgw_group', |
735 | 735 | 'acl_location' => $account_id, |
736 | - ),__LINE__,__FILE__); |
|
736 | + ), __LINE__, __FILE__); |
|
737 | 737 | } |
738 | 738 | } |
739 | 739 | |
@@ -744,15 +744,15 @@ discard block |
||
744 | 744 | * @param string $app app optional defaults to $GLOBALS['egw_info']['flags']['currentapp']; |
745 | 745 | * @return array with location => array(account => rights) pairs |
746 | 746 | */ |
747 | - function get_location_grants($location,$app='') |
|
747 | + function get_location_grants($location, $app = '') |
|
748 | 748 | { |
749 | 749 | if (!$app) $app = $GLOBALS['egw_info']['flags']['currentapp']; |
750 | 750 | |
751 | 751 | $locations = array(); |
752 | - foreach($this->db->select(self::TABLE,'acl_location,acl_account,acl_rights',array( |
|
752 | + foreach ($this->db->select(self::TABLE, 'acl_location,acl_account,acl_rights', array( |
|
753 | 753 | 'acl_appname' => $app, |
754 | 754 | 'acl_location LIKE '.$this->db->quote($location), |
755 | - ),__LINE__,__FILE__) as $row) |
|
755 | + ), __LINE__, __FILE__) as $row) |
|
756 | 756 | { |
757 | 757 | if (($location = $row['acl_location']) != 'run') |
758 | 758 | { |
@@ -119,7 +119,10 @@ discard block |
||
119 | 119 | else |
120 | 120 | { |
121 | 121 | $acl_acc_list = (array)$GLOBALS['egw']->accounts->memberships($this->account_id, true); |
122 | - if (is_array($no_groups)) $acl_acc_list = array_diff($acl_acc_list,$no_groups); |
|
122 | + if (is_array($no_groups)) |
|
123 | + { |
|
124 | + $acl_acc_list = array_diff($acl_acc_list,$no_groups); |
|
125 | + } |
|
123 | 126 | array_unshift($acl_acc_list,$this->account_id); |
124 | 127 | } |
125 | 128 | |
@@ -157,7 +160,10 @@ discard block |
||
157 | 160 | */ |
158 | 161 | function add($appname,$location,$rights) |
159 | 162 | { |
160 | - if (!$appname) $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
|
163 | + if (!$appname) |
|
164 | + { |
|
165 | + $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
|
166 | + } |
|
161 | 167 | |
162 | 168 | $row = array( |
163 | 169 | 'appname' => $appname, |
@@ -179,7 +185,10 @@ discard block |
||
179 | 185 | */ |
180 | 186 | function delete($appname,$location) |
181 | 187 | { |
182 | - if (!$appname) $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
|
188 | + if (!$appname) |
|
189 | + { |
|
190 | + $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
|
191 | + } |
|
183 | 192 | |
184 | 193 | foreach($this->data as $idx => $value) |
185 | 194 | { |
@@ -217,10 +226,13 @@ discard block |
||
217 | 226 | } |
218 | 227 | } |
219 | 228 | if ($this->account_id == $GLOBALS['egw_info']['user']['account_id'] && |
220 | - method_exists($GLOBALS['egw'],'invalidate_session_cache')) // egw object in setup is limited |
|
229 | + method_exists($GLOBALS['egw'],'invalidate_session_cache')) |
|
230 | + { |
|
231 | + // egw object in setup is limited |
|
221 | 232 | { |
222 | 233 | $GLOBALS['egw']->invalidate_session_cache(); |
223 | 234 | } |
235 | + } |
|
224 | 236 | return $this->data; |
225 | 237 | } |
226 | 238 | |
@@ -248,7 +260,10 @@ discard block |
||
248 | 260 | { |
249 | 261 | $this->read_repository(); |
250 | 262 | } |
251 | - if (!$appname) $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
|
263 | + if (!$appname) |
|
264 | + { |
|
265 | + $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
|
266 | + } |
|
252 | 267 | |
253 | 268 | if (!count($this->data) && $GLOBALS['egw_info']['server']['acl_default'] != 'deny') |
254 | 269 | { |
@@ -297,7 +312,10 @@ discard block |
||
297 | 312 | */ |
298 | 313 | function get_specific_rights($location, $appname = '', $memberships=array()) |
299 | 314 | { |
300 | - if (!$appname) $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
|
315 | + if (!$appname) |
|
316 | + { |
|
317 | + $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
|
318 | + } |
|
301 | 319 | |
302 | 320 | if (!count($this->data) && $GLOBALS['egw_info']['server']['acl_default'] != 'deny') |
303 | 321 | { |
@@ -362,10 +380,13 @@ discard block |
||
362 | 380 | ),__LINE__,__FILE__); |
363 | 381 | |
364 | 382 | if ($invalidate_session && $account_id == $GLOBALS['egw_info']['user']['account_id'] && |
365 | - method_exists($GLOBALS['egw'],'invalidate_session_cache')) // egw object in setup is limited |
|
383 | + method_exists($GLOBALS['egw'],'invalidate_session_cache')) |
|
384 | + { |
|
385 | + // egw object in setup is limited |
|
366 | 386 | { |
367 | 387 | $GLOBALS['egw']->invalidate_session_cache(); |
368 | 388 | } |
389 | + } |
|
369 | 390 | return $this->db->affected_rows(); |
370 | 391 | } |
371 | 392 | |
@@ -397,16 +418,22 @@ discard block |
||
397 | 418 | $where['acl_account'] = $cache_accountid[$accountid] = get_account_id($accountid,$this->account_id); |
398 | 419 | } |
399 | 420 | } |
400 | - if ($app == '%' || $app == '%%') unset($where['acl_appname']); |
|
421 | + if ($app == '%' || $app == '%%') |
|
422 | + { |
|
423 | + unset($where['acl_appname']); |
|
424 | + } |
|
401 | 425 | |
402 | 426 | $this->db->delete(self::TABLE,$where,__LINE__,__FILE__); |
403 | 427 | |
404 | 428 | $deleted = $this->db->affected_rows(); |
405 | 429 | |
406 | - if ($invalidate_session && $deleted && method_exists($GLOBALS['egw'],'invalidate_session_cache')) // egw object in setup is limited |
|
430 | + if ($invalidate_session && $deleted && method_exists($GLOBALS['egw'],'invalidate_session_cache')) |
|
431 | + { |
|
432 | + // egw object in setup is limited |
|
407 | 433 | { |
408 | 434 | $GLOBALS['egw']->invalidate_session_cache(); |
409 | 435 | } |
436 | + } |
|
410 | 437 | return $deleted; |
411 | 438 | } |
412 | 439 | |
@@ -420,7 +447,10 @@ discard block |
||
420 | 447 | */ |
421 | 448 | function get_specific_rights_for_account($account_id,$location,$appname='') |
422 | 449 | { |
423 | - if (!$appname) $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
|
450 | + if (!$appname) |
|
451 | + { |
|
452 | + $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
|
453 | + } |
|
424 | 454 | |
425 | 455 | return $this->db->select(self::TABLE,'acl_rights',array( |
426 | 456 | 'acl_location' => $location, |
@@ -438,7 +468,10 @@ discard block |
||
438 | 468 | */ |
439 | 469 | function get_all_rights($location,$appname='') |
440 | 470 | { |
441 | - if (!$appname) $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
|
471 | + if (!$appname) |
|
472 | + { |
|
473 | + $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
|
474 | + } |
|
442 | 475 | |
443 | 476 | $rights = array(); |
444 | 477 | foreach($this->db->select(self::TABLE,'acl_account,acl_rights',array( |
@@ -461,7 +494,10 @@ discard block |
||
461 | 494 | */ |
462 | 495 | function get_all_location_rights($account_id,$appname='',$use_memberships=true) |
463 | 496 | { |
464 | - if (!$appname) $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
|
497 | + if (!$appname) |
|
498 | + { |
|
499 | + $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
|
500 | + } |
|
465 | 501 | |
466 | 502 | $accounts = array($account_id); |
467 | 503 | if ($use_memberships && (int)$account_id > 0) |
@@ -565,7 +601,10 @@ discard block |
||
565 | 601 | */ |
566 | 602 | function get_ids_for_location($location, $required, $app = '') |
567 | 603 | { |
568 | - if (!$app) $app = $GLOBALS['egw_info']['flags']['currentapp']; |
|
604 | + if (!$app) |
|
605 | + { |
|
606 | + $app = $GLOBALS['egw_info']['flags']['currentapp']; |
|
607 | + } |
|
569 | 608 | |
570 | 609 | $accounts = false; |
571 | 610 | foreach($this->db->select(self::TABLE,array('acl_account','acl_rights'),array( |
@@ -589,7 +628,10 @@ discard block |
||
589 | 628 | */ |
590 | 629 | function get_locations_for_app($app='') |
591 | 630 | { |
592 | - if (!$app) $app = $GLOBALS['egw_info']['flags']['currentapp']; |
|
631 | + if (!$app) |
|
632 | + { |
|
633 | + $app = $GLOBALS['egw_info']['flags']['currentapp']; |
|
634 | + } |
|
593 | 635 | |
594 | 636 | $locations = false; |
595 | 637 | foreach($this->db->select(self::TABLE,'DISTINCT '.'acl_location',array( |
@@ -625,7 +667,10 @@ discard block |
||
625 | 667 | $account_id = get_account_id($accountid,$this->account_id); |
626 | 668 | $cache_accountid[$accountid] = $account_id; |
627 | 669 | } |
628 | - if ($use_memberships && (int)$account_id > 0) $memberships = $GLOBALS['egw']->accounts->memberships($account_id, true); |
|
670 | + if ($use_memberships && (int)$account_id > 0) |
|
671 | + { |
|
672 | + $memberships = $GLOBALS['egw']->accounts->memberships($account_id, true); |
|
673 | + } |
|
629 | 674 | $memberships[] = (int)$account_id; |
630 | 675 | |
631 | 676 | $apps = array(); |
@@ -659,15 +704,24 @@ discard block |
||
659 | 704 | */ |
660 | 705 | function get_grants($app='',$enum_group_acls=true,$user=null) |
661 | 706 | { |
662 | - if (!$app) $app = $GLOBALS['egw_info']['flags']['currentapp']; |
|
663 | - if (!$user) $user = $this->account_id; |
|
707 | + if (!$app) |
|
708 | + { |
|
709 | + $app = $GLOBALS['egw_info']['flags']['currentapp']; |
|
710 | + } |
|
711 | + if (!$user) |
|
712 | + { |
|
713 | + $user = $this->account_id; |
|
714 | + } |
|
664 | 715 | |
665 | 716 | static $cache = array(); // some caching withing the request |
666 | 717 | |
667 | 718 | $grants =& $cache[$app][$user]; |
668 | 719 | if (!isset($grants)) |
669 | 720 | { |
670 | - if ((int)$user > 0) $memberships = $GLOBALS['egw']->accounts->memberships($user, true); |
|
721 | + if ((int)$user > 0) |
|
722 | + { |
|
723 | + $memberships = $GLOBALS['egw']->accounts->memberships($user, true); |
|
724 | + } |
|
671 | 725 | $memberships[] = $user; |
672 | 726 | |
673 | 727 | $grants = $accounts = Array(); |
@@ -692,7 +746,11 @@ discard block |
||
692 | 746 | // return the grant for each member of the group (false = also for no longer active users) |
693 | 747 | foreach((array)$GLOBALS['egw']->accounts->members($grantor, true, false) as $grantor) |
694 | 748 | { |
695 | - if (!$grantor) continue; // can happen if group has no members |
|
749 | + if (!$grantor) |
|
750 | + { |
|
751 | + continue; |
|
752 | + } |
|
753 | + // can happen if group has no members |
|
696 | 754 | |
697 | 755 | // Don't allow to override private with group ACL's! |
698 | 756 | $rights &= ~self::PRIVAT; |
@@ -746,7 +804,10 @@ discard block |
||
746 | 804 | */ |
747 | 805 | function get_location_grants($location,$app='') |
748 | 806 | { |
749 | - if (!$app) $app = $GLOBALS['egw_info']['flags']['currentapp']; |
|
807 | + if (!$app) |
|
808 | + { |
|
809 | + $app = $GLOBALS['egw_info']['flags']['currentapp']; |
|
810 | + } |
|
750 | 811 | |
751 | 812 | $locations = array(); |
752 | 813 | foreach($this->db->select(self::TABLE,'acl_location,acl_account,acl_rights',array( |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | * cancels a timer |
325 | 325 | * |
326 | 326 | * @param string $id has to be the one used to set it. |
327 | - * @return boolean True if the timer exists and is not expired. |
|
327 | + * @return integer True if the timer exists and is not expired. |
|
328 | 328 | */ |
329 | 329 | function cancel_timer($id) |
330 | 330 | { |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | /** |
471 | 471 | * reads all matching db-rows / jobs |
472 | 472 | * |
473 | - * @param string $id =0 reads all expired rows / jobs ready to run\ |
|
473 | + * @param integer $id =0 reads all expired rows / jobs ready to run\ |
|
474 | 474 | * != 0 reads all rows/jobs matching $id (sql-wildcards '%' and '_' can be used) |
475 | 475 | * @param array|string $cols ='*' string or array of column-names / select-expressions |
476 | 476 | * @param int|bool $offset =False offset for a limited query or False (default) |
@@ -558,7 +558,7 @@ discard block |
||
558 | 558 | /** |
559 | 559 | * delete db-row / job with $id |
560 | 560 | * |
561 | - * @return boolean False if $id not found else True |
|
561 | + * @return integer False if $id not found else True |
|
562 | 562 | */ |
563 | 563 | function delete($id) |
564 | 564 | { |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | /** |
44 | 44 | * Time to keep expired jobs marked as "keep", until they got finally deleted |
45 | 45 | */ |
46 | - const DEFAULT_KEEP_TIME = 86400; // 1day |
|
46 | + const DEFAULT_KEEP_TIME = 86400; // 1day |
|
47 | 47 | |
48 | 48 | /** |
49 | 49 | * constructor of the class |
@@ -58,9 +58,9 @@ discard block |
||
58 | 58 | { |
59 | 59 | $this->db = $GLOBALS['egw_setup']->db; |
60 | 60 | } |
61 | - $this->cronline = EGW_SERVER_ROOT . '/api/asyncservices.php '.$GLOBALS['egw_info']['user']['domain']; |
|
61 | + $this->cronline = EGW_SERVER_ROOT.'/api/asyncservices.php '.$GLOBALS['egw_info']['user']['domain']; |
|
62 | 62 | |
63 | - $this->only_fallback = substr(php_uname(), 0, 7) == "Windows"; // atm cron-jobs dont work on win |
|
63 | + $this->only_fallback = substr(php_uname(), 0, 7) == "Windows"; // atm cron-jobs dont work on win |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -83,10 +83,10 @@ discard block |
||
83 | 83 | * @param boolean $allow_past =false allow to set alarms in the past eg. with times===0 to not trigger it in next run |
84 | 84 | * @return boolean False if $id already exists, else True |
85 | 85 | */ |
86 | - function set_timer($times, $id, $method, $data=null, $account_id=False, $debug=false, $allow_past=false) |
|
86 | + function set_timer($times, $id, $method, $data = null, $account_id = False, $debug = false, $allow_past = false) |
|
87 | 87 | { |
88 | 88 | if (empty($id) || empty($method) || $this->read($id) || |
89 | - !($next = $this->next_run($times,$debug))) |
|
89 | + !($next = $this->next_run($times, $debug))) |
|
90 | 90 | { |
91 | 91 | // allow to set "keep" alarms in the past ($next === false) |
92 | 92 | if ($next === false && !is_array($times) && $allow_past) |
@@ -129,14 +129,14 @@ discard block |
||
129 | 129 | * @param int $now Use this time to calculate then next run from. Defaults to time(). |
130 | 130 | * @return int a unix timestamp of the next execution time or False if no more executions |
131 | 131 | */ |
132 | - function next_run($times,$debug=False, $now = null) |
|
132 | + function next_run($times, $debug = False, $now = null) |
|
133 | 133 | { |
134 | 134 | if ($this->debug) |
135 | 135 | { |
136 | - error_log(__METHOD__."(".array2string($times).", '$debug', " . date('Y-m-d H:i', $now) . ")"); |
|
137 | - $debug = True; // enable syntax-error messages too |
|
136 | + error_log(__METHOD__."(".array2string($times).", '$debug', ".date('Y-m-d H:i', $now).")"); |
|
137 | + $debug = True; // enable syntax-error messages too |
|
138 | 138 | } |
139 | - if(is_null($now)) { |
|
139 | + if (is_null($now)) { |
|
140 | 140 | $now = time(); |
141 | 141 | } |
142 | 142 | |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | 'dow' => 6, |
165 | 165 | 'day' => 31, |
166 | 166 | 'month' => 12, |
167 | - 'year' => date('Y')+10 // else */[0-9] would never stop returning numbers |
|
167 | + 'year' => date('Y') + 10 // else */[0-9] would never stop returning numbers |
|
168 | 168 | ); |
169 | 169 | $min_unit = array( |
170 | 170 | 'min' => 0, |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | // get set to the minimum after |
181 | 181 | // |
182 | 182 | $i = $first_set = $last_set = 0; |
183 | - foreach($units as $u => $date_pattern) |
|
183 | + foreach ($units as $u => $date_pattern) |
|
184 | 184 | { |
185 | 185 | ++$i; |
186 | 186 | if (isset($times[$u])) |
@@ -198,24 +198,24 @@ discard block |
||
198 | 198 | // (as descript above), enumerations are arrays with unit-values as keys |
199 | 199 | // |
200 | 200 | $n = 0; |
201 | - foreach($units as $u => $date_pattern) |
|
201 | + foreach ($units as $u => $date_pattern) |
|
202 | 202 | { |
203 | 203 | ++$n; |
204 | - if ($this->debug) error_log("n=$n, $u: isset(times[$u]=".array2string($times[$u]).")=".(isset($times[$u])?'True':'False')); |
|
204 | + if ($this->debug) error_log("n=$n, $u: isset(times[$u]=".array2string($times[$u]).")=".(isset($times[$u]) ? 'True' : 'False')); |
|
205 | 205 | if (isset($times[$u])) |
206 | 206 | { |
207 | - if(is_array($times[$u])) { |
|
207 | + if (is_array($times[$u])) { |
|
208 | 208 | $time = array_keys($times[$u]); |
209 | 209 | } else { |
210 | - $time = explode(',',$times[$u]); |
|
210 | + $time = explode(',', $times[$u]); |
|
211 | 211 | } |
212 | 212 | $times[$u] = array(); |
213 | 213 | |
214 | - foreach($time as $t) |
|
214 | + foreach ($time as $t) |
|
215 | 215 | { |
216 | - if (strpos($t,'-') !== False && strpos($t,'/') === False) |
|
216 | + if (strpos($t, '-') !== False && strpos($t, '/') === False) |
|
217 | 217 | { |
218 | - list($min,$max) = $arr = explode('-',$t); |
|
218 | + list($min, $max) = $arr = explode('-', $t); |
|
219 | 219 | |
220 | 220 | if (count($arr) != 2 || !is_numeric($min) || !is_numeric($max) || $min > $max) |
221 | 221 | { |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | { |
233 | 233 | if ((string)$t == '*') $t = '*/1'; |
234 | 234 | |
235 | - list($one,$inc) = $arr = explode('/',$t); |
|
235 | + list($one, $inc) = $arr = explode('/', $t); |
|
236 | 236 | |
237 | 237 | if (!(is_numeric($one) && count($arr) == 1 || |
238 | 238 | count($arr) == 2 && is_numeric($inc))) |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | } |
248 | 248 | else |
249 | 249 | { |
250 | - list($min,$max) = $arr = explode('-',$one); |
|
250 | + list($min, $max) = $arr = explode('-', $one); |
|
251 | 251 | if (empty($one) || $one == '*') |
252 | 252 | { |
253 | 253 | $min = $min_unit[$u]; |
@@ -288,20 +288,19 @@ discard block |
||
288 | 288 | { |
289 | 289 | $future = False; |
290 | 290 | |
291 | - foreach($units as $u => $date_pattern) |
|
291 | + foreach ($units as $u => $date_pattern) |
|
292 | 292 | { |
293 | - $unit_now = $u != 'dow' ? (int)date($date_pattern, $now) : |
|
294 | - (int)date($date_pattern,mktime(12,0,0,$found['month'],$found['day'],$found['year'])); |
|
293 | + $unit_now = $u != 'dow' ? (int)date($date_pattern, $now) : (int)date($date_pattern, mktime(12, 0, 0, $found['month'], $found['day'], $found['year'])); |
|
295 | 294 | |
296 | 295 | if (isset($found[$u])) |
297 | 296 | { |
298 | 297 | $future = $future || $found[$u] > $unit_now; |
299 | 298 | if ($this->debug) error_log("--> already have a $u = ".$found[$u].", future='$future'"); |
300 | - continue; // already set |
|
299 | + continue; // already set |
|
301 | 300 | } |
302 | - foreach(array_keys($times[$u]) as $unit_value) |
|
301 | + foreach (array_keys($times[$u]) as $unit_value) |
|
303 | 302 | { |
304 | - switch($u) |
|
303 | + switch ($u) |
|
305 | 304 | { |
306 | 305 | case 'dow': |
307 | 306 | $valid = $unit_value == $unit_now; |
@@ -324,12 +323,12 @@ discard block |
||
324 | 323 | if (!isset($found[$u])) // we have to try the next one, if it exists |
325 | 324 | { |
326 | 325 | $nexts = array_keys($units); |
327 | - if (!isset($nexts[count($found)-1])) |
|
326 | + if (!isset($nexts[count($found) - 1])) |
|
328 | 327 | { |
329 | 328 | if ($this->debug) error_log("Nothing found, exiting !!!"); |
330 | 329 | return False; |
331 | 330 | } |
332 | - $next = $nexts[count($found)-1]; |
|
331 | + $next = $nexts[count($found) - 1]; |
|
333 | 332 | $over = $found[$next]; |
334 | 333 | unset($found[$next]); |
335 | 334 | if ($this->debug) error_log("Have to try the next $next, $u's are over for $next=$over !!!"); |
@@ -339,7 +338,7 @@ discard block |
||
339 | 338 | } |
340 | 339 | if ($this->debug) error_log("next=".array2string($found)); |
341 | 340 | |
342 | - return mktime($found['hour'],$found['min'],0,$found['month'],$found['day'],$found['year']); |
|
341 | + return mktime($found['hour'], $found['min'], 0, $found['month'], $found['day'], $found['year']); |
|
343 | 342 | } |
344 | 343 | |
345 | 344 | /** |
@@ -361,7 +360,7 @@ discard block |
||
361 | 360 | * @return mixed if !$set array('start' => $start,'end' => $end) with timestamps of last check_run start and end, \ |
362 | 361 | * !$end means check_run is just running. If $set returns True if it was able to get the semaphore, else False |
363 | 362 | */ |
364 | - function last_check_run($semaphore=False,$release=False,$run_by='') |
|
363 | + function last_check_run($semaphore = False, $release = False, $run_by = '') |
|
365 | 364 | { |
366 | 365 | //echo "<p>last_check_run(semaphore=".($semaphore?'True':'False').",release=".($release?'True':'False').")</p>\n"; |
367 | 366 | if (($exists = $this->read('##last-check-run##'))) |
@@ -383,7 +382,7 @@ discard block |
||
383 | 382 | } |
384 | 383 | else |
385 | 384 | { |
386 | - @set_time_limit(0); // dont stop for an execution-time-limit |
|
385 | + @set_time_limit(0); // dont stop for an execution-time-limit |
|
387 | 386 | ignore_user_abort(True); |
388 | 387 | |
389 | 388 | $last_run = array( |
@@ -399,7 +398,7 @@ discard block |
||
399 | 398 | ); |
400 | 399 | // as the async_next column is used as a semaphore we only update it, |
401 | 400 | // if it is 0 (semaphore released) or older then 10min to recover from failed or crashed attempts |
402 | - if ($exists) $where = array('(async_next=0 OR async_next<'.(time()-600).')'); |
|
401 | + if ($exists) $where = array('(async_next=0 OR async_next<'.(time() - 600).')'); |
|
403 | 402 | } |
404 | 403 | //echo "last_run=<pre>"; print_r($last_run); echo "</pre>\n"; |
405 | 404 | return $this->write($last_run, !!$exists, $where) > 0; |
@@ -408,20 +407,20 @@ discard block |
||
408 | 407 | /** |
409 | 408 | * checks if there are any jobs ready to run (timer expired) and executes them |
410 | 409 | */ |
411 | - function check_run($run_by='') |
|
410 | + function check_run($run_by = '') |
|
412 | 411 | { |
413 | 412 | if ($run_by === 'fallback') flush(); |
414 | 413 | |
415 | - if (!$this->last_check_run(True,False,$run_by)) |
|
414 | + if (!$this->last_check_run(True, False, $run_by)) |
|
416 | 415 | { |
417 | - return False; // cant obtain semaphore |
|
416 | + return False; // cant obtain semaphore |
|
418 | 417 | } |
419 | 418 | // mark enviroment as async-service, check with isset()! |
420 | 419 | $GLOBALS['egw_info']['flags']['async-service'] = $run_by; |
421 | 420 | |
422 | 421 | if (($jobs = $this->read())) |
423 | 422 | { |
424 | - foreach($jobs as $job) |
|
423 | + foreach ($jobs as $job) |
|
425 | 424 | { |
426 | 425 | // checking / setting up egw_info/user |
427 | 426 | // |
@@ -430,7 +429,7 @@ discard block |
||
430 | 429 | // run notifications, before changing account_id of enviroment |
431 | 430 | Link::run_notifies(); |
432 | 431 | // unset all objects in $GLOBALS, which are created and used by ExecMethod, as they can contain user-data |
433 | - foreach($GLOBALS as $name => $value) |
|
432 | + foreach ($GLOBALS as $name => $value) |
|
434 | 433 | { |
435 | 434 | if ($name !== 'egw' && is_object($value)) unset($GLOBALS[$name]); |
436 | 435 | } |
@@ -442,7 +441,7 @@ discard block |
||
442 | 441 | { |
443 | 442 | $GLOBALS['egw']->session->account_lid = $GLOBALS['egw']->accounts->id2name($job['account_id']); |
444 | 443 | $GLOBALS['egw']->session->account_domain = $domain; |
445 | - $GLOBALS['egw_info']['user'] = $GLOBALS['egw']->session->read_repositories(); |
|
444 | + $GLOBALS['egw_info']['user'] = $GLOBALS['egw']->session->read_repositories(); |
|
446 | 445 | |
447 | 446 | if ($lang != $GLOBALS['egw_info']['user']['preferences']['common']['lang']) |
448 | 447 | { |
@@ -457,12 +456,11 @@ discard block |
||
457 | 456 | $GLOBALS['egw_info']['user']['domain'] = $domain; |
458 | 457 | } |
459 | 458 | } |
460 | - list($app) = strpos($job['method'],'::') !== false ? explode('_',$job['method']) : |
|
461 | - explode('.',$job['method']); |
|
459 | + list($app) = strpos($job['method'], '::') !== false ? explode('_', $job['method']) : explode('.', $job['method']); |
|
462 | 460 | Translation::add_app($app); |
463 | 461 | if (is_array($job['data'])) |
464 | 462 | { |
465 | - $job['data'] += array_diff_key($job,array('data' => false)); |
|
463 | + $job['data'] += array_diff_key($job, array('data' => false)); |
|
466 | 464 | } |
467 | 465 | |
468 | 466 | if ($this->debug) error_log(__METHOD__."() processing job ".array2string($job)); |
@@ -498,16 +496,16 @@ discard block |
||
498 | 496 | try |
499 | 497 | { |
500 | 498 | if ($this->debug) error_log(__METHOD__."() running job ".array2string($job)); |
501 | - ExecMethod($job['method'],$job['data']); |
|
499 | + ExecMethod($job['method'], $job['data']); |
|
502 | 500 | } |
503 | - catch(Exception $e) |
|
501 | + catch (Exception $e) |
|
504 | 502 | { |
505 | 503 | // log the exception to error_log, but continue running other async jobs |
506 | 504 | _egw_log_exception($e); |
507 | 505 | } |
508 | 506 | } |
509 | 507 | } |
510 | - $this->last_check_run(True,True,$run_by); // release semaphore |
|
508 | + $this->last_check_run(True, True, $run_by); // release semaphore |
|
511 | 509 | |
512 | 510 | return $jobs ? count($jobs) : 0; |
513 | 511 | } |
@@ -523,7 +521,7 @@ discard block |
||
523 | 521 | * @param int $num_rows =0 number of rows to return if offset set, default 0 = use default in user prefs |
524 | 522 | * @return array/boolean db-rows / jobs as array or False if no matches |
525 | 523 | */ |
526 | - function read($id=0,$cols='*',$offset=False,$append='ORDER BY async_next',$num_rows=0) |
|
524 | + function read($id = 0, $cols = '*', $offset = False, $append = 'ORDER BY async_next', $num_rows = 0) |
|
527 | 525 | { |
528 | 526 | if (!is_a($this->db, 'EGroupware\\Api\\Db')) return false; |
529 | 527 | |
@@ -531,7 +529,7 @@ discard block |
||
531 | 529 | { |
532 | 530 | $where = "async_id != '##last-check-run##'"; |
533 | 531 | } |
534 | - elseif (!is_array($id) && (strpos($id,'%') !== False || strpos($id,'_') !== False)) |
|
532 | + elseif (!is_array($id) && (strpos($id, '%') !== False || strpos($id, '_') !== False)) |
|
535 | 533 | { |
536 | 534 | $id = $this->db->quote($id); |
537 | 535 | $where = "async_id LIKE $id AND async_id != '##last-check-run##'"; |
@@ -545,21 +543,21 @@ discard block |
||
545 | 543 | $where = array('async_id' => $id); |
546 | 544 | } |
547 | 545 | $jobs = array(); |
548 | - foreach($this->db->select($this->db_table,$cols,$where,__LINE__,__FILE__,$offset,$append,False,$num_rows) as $row) |
|
546 | + foreach ($this->db->select($this->db_table, $cols, $where, __LINE__, __FILE__, $offset, $append, False, $num_rows) as $row) |
|
549 | 547 | { |
550 | 548 | $row['async_times'] = json_php_unserialize($row['async_times']); |
551 | 549 | // check for broken value during migration |
552 | 550 | if ($row['async_data'][0] == '"' && substr($row['async_data'], 0, 7) == '"\\"\\\\\\"') |
553 | 551 | { |
554 | 552 | $row['async_data'] = null; |
555 | - $this->write(Db::strip_array_keys($row,'async_'), true); |
|
553 | + $this->write(Db::strip_array_keys($row, 'async_'), true); |
|
556 | 554 | } |
557 | 555 | else |
558 | 556 | { |
559 | 557 | $row['async_data'] = !empty($row['async_data']) ? |
560 | - json_php_unserialize($row['async_data'], true) : null; // allow non-serialized data |
|
558 | + json_php_unserialize($row['async_data'], true) : null; // allow non-serialized data |
|
561 | 559 | } |
562 | - $jobs[$row['async_id']] = Db::strip_array_keys($row,'async_'); |
|
560 | + $jobs[$row['async_id']] = Db::strip_array_keys($row, 'async_'); |
|
563 | 561 | } |
564 | 562 | if (!count($jobs)) |
565 | 563 | { |
@@ -576,7 +574,7 @@ discard block |
||
576 | 574 | * @param array $where additional where statemetn to update only if a certain condition is met, used for the semaphore |
577 | 575 | * @return int affected rows, can be 0 if an additional where statement is given |
578 | 576 | */ |
579 | - function write($job, $exists = False, $where=array()) |
|
577 | + function write($job, $exists = False, $where = array()) |
|
580 | 578 | { |
581 | 579 | if (!is_a($this->db, 'EGroupware\\Api\\Db')) return 0; |
582 | 580 | |
@@ -608,7 +606,7 @@ discard block |
||
608 | 606 | function delete($id) |
609 | 607 | { |
610 | 608 | if ($this->debug) error_log(__METHOD__."('$id') ".function_backtrace()); |
611 | - $this->db->delete($this->db_table,array('async_id' => $id),__LINE__,__FILE__); |
|
609 | + $this->db->delete($this->db_table, array('async_id' => $id), __LINE__, __FILE__); |
|
612 | 610 | |
613 | 611 | return $this->db->affected_rows(); |
614 | 612 | } |
@@ -633,38 +631,38 @@ discard block |
||
633 | 631 | { |
634 | 632 | $binarys = array( |
635 | 633 | 'php' => '/usr/bin/php', |
636 | - 'php5' => '/usr/bin/php5', // SuSE 9.3 with php5 |
|
634 | + 'php5' => '/usr/bin/php5', // SuSE 9.3 with php5 |
|
637 | 635 | 'crontab' => '/usr/bin/crontab' |
638 | 636 | ); |
639 | 637 | foreach ($binarys as $name => $path) |
640 | 638 | { |
641 | - $this->$name = $path; // a reasonable default for *nix |
|
639 | + $this->$name = $path; // a reasonable default for *nix |
|
642 | 640 | |
643 | 641 | if (!($Ok = @is_executable($this->$name))) |
644 | 642 | { |
645 | 643 | if (file_exists($this->$name)) |
646 | 644 | { |
647 | - echo '<p>'.lang('%1 is not executable by the webserver !!!',$this->$name)."</p>\n"; |
|
645 | + echo '<p>'.lang('%1 is not executable by the webserver !!!', $this->$name)."</p>\n"; |
|
648 | 646 | $perms = fileperms($this->$name); |
649 | - if (!($perms & 0x0001) && ($perms & 0x0008) && function_exists('posix_getuid')) // only executable by group |
|
647 | + if (!($perms&0x0001) && ($perms&0x0008) && function_exists('posix_getuid')) // only executable by group |
|
650 | 648 | { |
651 | 649 | $group = posix_getgrgid(filegroup($this->$name)); |
652 | - $webserver = posix_getpwuid(posix_getuid ()); |
|
653 | - echo '<p>'.lang("You need to add the webserver user '%1' to the group '%2'.",$webserver['name'],$group['name'])."</p>\n"; } |
|
650 | + $webserver = posix_getpwuid(posix_getuid()); |
|
651 | + echo '<p>'.lang("You need to add the webserver user '%1' to the group '%2'.", $webserver['name'], $group['name'])."</p>\n"; } |
|
654 | 652 | } |
655 | - if (($fd = popen('/bin/sh -c "type -p '.$name.'"','r'))) |
|
653 | + if (($fd = popen('/bin/sh -c "type -p '.$name.'"', 'r'))) |
|
656 | 654 | { |
657 | - $this->$name = fgets($fd,256); |
|
655 | + $this->$name = fgets($fd, 256); |
|
658 | 656 | @pclose($fd); |
659 | 657 | } |
660 | - if (($pos = strpos($this->$name,"\n"))) |
|
658 | + if (($pos = strpos($this->$name, "\n"))) |
|
661 | 659 | { |
662 | - $this->$name = substr($this->$name,0,$pos); |
|
660 | + $this->$name = substr($this->$name, 0, $pos); |
|
663 | 661 | } |
664 | 662 | } |
665 | 663 | if (!$Ok && !@is_executable($this->$name)) |
666 | 664 | { |
667 | - $this->$name = $name; // hopefully its in the path |
|
665 | + $this->$name = $name; // hopefully its in the path |
|
668 | 666 | } |
669 | 667 | //echo "<p>$name = '".$this->$name."'</p>\n"; |
670 | 668 | } |
@@ -686,7 +684,7 @@ discard block |
||
686 | 684 | * |
687 | 685 | * @return int |
688 | 686 | */ |
689 | - function installed(array &$other_cronlines=array()) |
|
687 | + function installed(array &$other_cronlines = array()) |
|
690 | 688 | { |
691 | 689 | if ($this->only_fallback) { |
692 | 690 | return 0; |
@@ -700,15 +698,15 @@ discard block |
||
700 | 698 | } |
701 | 699 | $times = False; |
702 | 700 | $other_cronlines = array(); |
703 | - if (($crontab = popen('/bin/sh -c "'.$this->crontab.' -l" 2>&1','r')) !== False) |
|
701 | + if (($crontab = popen('/bin/sh -c "'.$this->crontab.' -l" 2>&1', 'r')) !== False) |
|
704 | 702 | { |
705 | 703 | $n = 0; |
706 | - while ($line = fgets($crontab,256)) |
|
704 | + while ($line = fgets($crontab, 256)) |
|
707 | 705 | { |
708 | 706 | if ($this->debug) error_log(__METHOD__.'() line '.++$n.": $line"); |
709 | - $parts = explode(' ',$line,6); |
|
707 | + $parts = explode(' ', $line, 6); |
|
710 | 708 | |
711 | - if ($line{0} == '#' || count($parts) < 6 || ($parts[5]{0} != '/' && substr($parts[5],0,3) != 'php')) |
|
709 | + if ($line{0} == '#' || count($parts) < 6 || ($parts[5]{0} != '/' && substr($parts[5], 0, 3) != 'php')) |
|
712 | 710 | { |
713 | 711 | // ignore comments |
714 | 712 | if ($line{0} != '#') |
@@ -716,12 +714,12 @@ discard block |
||
716 | 714 | $times['error'] .= $line; |
717 | 715 | } |
718 | 716 | } |
719 | - elseif (strpos($line,$this->cronline) !== False || |
|
717 | + elseif (strpos($line, $this->cronline) !== False || |
|
720 | 718 | // also check of old phpgwapi/cron path |
721 | 719 | strpos($line, str_replace('/api/', '/phpgwapi/cron/', $this->cronline)) !== False) |
722 | 720 | { |
723 | - $cron_units = array('min','hour','day','month','dow'); |
|
724 | - foreach($cron_units as $n => $u) |
|
721 | + $cron_units = array('min', 'hour', 'day', 'month', 'dow'); |
|
722 | + foreach ($cron_units as $n => $u) |
|
725 | 723 | { |
726 | 724 | $times[$u] = $parts[$n]; |
727 | 725 | } |
@@ -753,26 +751,26 @@ discard block |
||
753 | 751 | return 0; |
754 | 752 | } |
755 | 753 | $other_cronlines = array(); |
756 | - $this->installed($other_cronlines); // find other installed cronlines |
|
754 | + $this->installed($other_cronlines); // find other installed cronlines |
|
757 | 755 | |
758 | - if (($crontab = popen('/bin/sh -c "'.$this->crontab.' -" 2>&1','w')) !== False) |
|
756 | + if (($crontab = popen('/bin/sh -c "'.$this->crontab.' -" 2>&1', 'w')) !== False) |
|
759 | 757 | { |
760 | 758 | foreach ($other_cronlines as $cronline) |
761 | 759 | { |
762 | - fwrite($crontab,$cronline); // preserv the other lines on install |
|
760 | + fwrite($crontab, $cronline); // preserv the other lines on install |
|
763 | 761 | } |
764 | 762 | if ($times !== False) |
765 | 763 | { |
766 | - $cron_units = array('min','hour','day','month','dow'); |
|
764 | + $cron_units = array('min', 'hour', 'day', 'month', 'dow'); |
|
767 | 765 | $cronline = ''; |
768 | - foreach($cron_units as $cu) |
|
766 | + foreach ($cron_units as $cu) |
|
769 | 767 | { |
770 | - $cronline .= (isset($times[$cu]) ? $times[$cu] : '*') . ' '; |
|
768 | + $cronline .= (isset($times[$cu]) ? $times[$cu] : '*').' '; |
|
771 | 769 | } |
772 | 770 | // -d memory_limit=-1 --> no memory limit |
773 | 771 | $cronline .= $this->php.' -q -d memory_limit=-1 '.$this->cronline."\n"; |
774 | 772 | //echo "<p>Installing: '$cronline'</p>\n"; |
775 | - fwrite($crontab,$cronline); |
|
773 | + fwrite($crontab, $cronline); |
|
776 | 774 | } |
777 | 775 | @pclose($crontab); |
778 | 776 | } |
@@ -95,7 +95,10 @@ discard block |
||
95 | 95 | } |
96 | 96 | else |
97 | 97 | { |
98 | - if ($this->debug) error_log(__METHOD__."(".array2string($times).", '$id', '$method', ".array2string($data).", $account_id, $debug, $allow_past) returning FALSE"); |
|
98 | + if ($this->debug) |
|
99 | + { |
|
100 | + error_log(__METHOD__."(".array2string($times).", '$id', '$method', ".array2string($data).", $account_id, $debug, $allow_past) returning FALSE"); |
|
101 | + } |
|
99 | 102 | return False; |
100 | 103 | } |
101 | 104 | } |
@@ -113,7 +116,10 @@ discard block |
||
113 | 116 | ); |
114 | 117 | $this->write($job); |
115 | 118 | |
116 | - if ($this->debug) error_log(__METHOD__."(".array2string($times).", '$id', '$method', ".array2string($data).", $account_id, $debug, $allow_past) returning TRUE"); |
|
119 | + if ($this->debug) |
|
120 | + { |
|
121 | + error_log(__METHOD__."(".array2string($times).", '$id', '$method', ".array2string($data).", $account_id, $debug, $allow_past) returning TRUE"); |
|
122 | + } |
|
117 | 123 | return True; |
118 | 124 | } |
119 | 125 | |
@@ -136,7 +142,8 @@ discard block |
||
136 | 142 | error_log(__METHOD__."(".array2string($times).", '$debug', " . date('Y-m-d H:i', $now) . ")"); |
137 | 143 | $debug = True; // enable syntax-error messages too |
138 | 144 | } |
139 | - if(is_null($now)) { |
|
145 | + if(is_null($now)) |
|
146 | + { |
|
140 | 147 | $now = time(); |
141 | 148 | } |
142 | 149 | |
@@ -201,12 +208,18 @@ discard block |
||
201 | 208 | foreach($units as $u => $date_pattern) |
202 | 209 | { |
203 | 210 | ++$n; |
204 | - if ($this->debug) error_log("n=$n, $u: isset(times[$u]=".array2string($times[$u]).")=".(isset($times[$u])?'True':'False')); |
|
211 | + if ($this->debug) |
|
212 | + { |
|
213 | + error_log("n=$n, $u: isset(times[$u]=".array2string($times[$u]).")=".(isset($times[$u])?'True':'False')); |
|
214 | + } |
|
205 | 215 | if (isset($times[$u])) |
206 | 216 | { |
207 | - if(is_array($times[$u])) { |
|
217 | + if(is_array($times[$u])) |
|
218 | + { |
|
208 | 219 | $time = array_keys($times[$u]); |
209 | - } else { |
|
220 | + } |
|
221 | + else |
|
222 | + { |
|
210 | 223 | $time = explode(',',$times[$u]); |
211 | 224 | } |
212 | 225 | $times[$u] = array(); |
@@ -219,7 +232,10 @@ discard block |
||
219 | 232 | |
220 | 233 | if (count($arr) != 2 || !is_numeric($min) || !is_numeric($max) || $min > $max) |
221 | 234 | { |
222 | - if ($debug) error_log("Syntax error in $u='$t', allowed is 'min-max', min <= max, min='$min', max='$max'"); |
|
235 | + if ($debug) |
|
236 | + { |
|
237 | + error_log("Syntax error in $u='$t', allowed is 'min-max', min <= max, min='$min', max='$max'"); |
|
238 | + } |
|
223 | 239 | |
224 | 240 | return False; |
225 | 241 | } |
@@ -230,14 +246,20 @@ discard block |
||
230 | 246 | } |
231 | 247 | else |
232 | 248 | { |
233 | - if ((string)$t == '*') $t = '*/1'; |
|
249 | + if ((string)$t == '*') |
|
250 | + { |
|
251 | + $t = '*/1'; |
|
252 | + } |
|
234 | 253 | |
235 | 254 | list($one,$inc) = $arr = explode('/',$t); |
236 | 255 | |
237 | 256 | if (!(is_numeric($one) && count($arr) == 1 || |
238 | 257 | count($arr) == 2 && is_numeric($inc))) |
239 | 258 | { |
240 | - if ($debug) error_log("Syntax error in $u='$t', allowed is a number or '{*|range}/inc', inc='$inc'"); |
|
259 | + if ($debug) |
|
260 | + { |
|
261 | + error_log("Syntax error in $u='$t', allowed is a number or '{*|range}/inc', inc='$inc'"); |
|
262 | + } |
|
241 | 263 | |
242 | 264 | return False; |
243 | 265 | } |
@@ -255,7 +277,10 @@ discard block |
||
255 | 277 | } |
256 | 278 | elseif (count($arr) != 2 || $min > $max) |
257 | 279 | { |
258 | - if ($debug) error_log("Syntax error in $u='$t', allowed is '{*|min-max}/inc', min='$min',max='$max', inc='$inc'"); |
|
280 | + if ($debug) |
|
281 | + { |
|
282 | + error_log("Syntax error in $u='$t', allowed is '{*|min-max}/inc', min='$min',max='$max', inc='$inc'"); |
|
283 | + } |
|
259 | 284 | return False; |
260 | 285 | } |
261 | 286 | for ($i = $min; $i <= $max; $i += $inc) |
@@ -266,9 +291,13 @@ discard block |
||
266 | 291 | } |
267 | 292 | } |
268 | 293 | } |
269 | - elseif ($n < $last_set || $u == 'dow') // before last value set (or dow) => empty gets enumerated |
|
294 | + elseif ($n < $last_set || $u == 'dow') |
|
270 | 295 | { |
271 | - for ($i = $min_unit[$u]; $i <= $max_unit[$u]; ++$i) |
|
296 | + // before last value set (or dow) => empty gets enumerated |
|
297 | + { |
|
298 | + for ($i = $min_unit[$u]; |
|
299 | + } |
|
300 | + $i <= $max_unit[$u]; ++$i) |
|
272 | 301 | { |
273 | 302 | $times[$u][$i] = True; |
274 | 303 | } |
@@ -278,7 +307,10 @@ discard block |
||
278 | 307 | $times[$u][$min_unit[$u]] = True; |
279 | 308 | } |
280 | 309 | } |
281 | - if ($this->debug) error_log("enumerated times=".array2string($times)); |
|
310 | + if ($this->debug) |
|
311 | + { |
|
312 | + error_log("enumerated times=".array2string($times)); |
|
313 | + } |
|
282 | 314 | |
283 | 315 | // now we have the times enumerated, lets find the first not expired one |
284 | 316 | // |
@@ -296,7 +328,10 @@ discard block |
||
296 | 328 | if (isset($found[$u])) |
297 | 329 | { |
298 | 330 | $future = $future || $found[$u] > $unit_now; |
299 | - if ($this->debug) error_log("--> already have a $u = ".$found[$u].", future='$future'"); |
|
331 | + if ($this->debug) |
|
332 | + { |
|
333 | + error_log("--> already have a $u = ".$found[$u].", future='$future'"); |
|
334 | + } |
|
300 | 335 | continue; // already set |
301 | 336 | } |
302 | 337 | foreach(array_keys($times[$u]) as $unit_value) |
@@ -314,30 +349,45 @@ discard block |
||
314 | 349 | break; |
315 | 350 | |
316 | 351 | } |
317 | - if ($valid && ($u != $next || $unit_value > $over)) // valid and not over |
|
352 | + if ($valid && ($u != $next || $unit_value > $over)) |
|
353 | + { |
|
354 | + // valid and not over |
|
318 | 355 | { |
319 | 356 | $found[$u] = $unit_value; |
357 | + } |
|
320 | 358 | $future = $future || $unit_value > $unit_now; |
321 | 359 | break; |
322 | 360 | } |
323 | 361 | } |
324 | - if (!isset($found[$u])) // we have to try the next one, if it exists |
|
362 | + if (!isset($found[$u])) |
|
363 | + { |
|
364 | + // we have to try the next one, if it exists |
|
325 | 365 | { |
326 | 366 | $nexts = array_keys($units); |
367 | + } |
|
327 | 368 | if (!isset($nexts[count($found)-1])) |
328 | 369 | { |
329 | - if ($this->debug) error_log("Nothing found, exiting !!!"); |
|
370 | + if ($this->debug) |
|
371 | + { |
|
372 | + error_log("Nothing found, exiting !!!"); |
|
373 | + } |
|
330 | 374 | return False; |
331 | 375 | } |
332 | 376 | $next = $nexts[count($found)-1]; |
333 | 377 | $over = $found[$next]; |
334 | 378 | unset($found[$next]); |
335 | - if ($this->debug) error_log("Have to try the next $next, $u's are over for $next=$over !!!"); |
|
379 | + if ($this->debug) |
|
380 | + { |
|
381 | + error_log("Have to try the next $next, $u's are over for $next=$over !!!"); |
|
382 | + } |
|
336 | 383 | break; |
337 | 384 | } |
338 | 385 | } |
339 | 386 | } |
340 | - if ($this->debug) error_log("next=".array2string($found)); |
|
387 | + if ($this->debug) |
|
388 | + { |
|
389 | + error_log("next=".array2string($found)); |
|
390 | + } |
|
341 | 391 | |
342 | 392 | return mktime($found['hour'],$found['min'],0,$found['month'],$found['day'],$found['year']); |
343 | 393 | } |
@@ -399,7 +449,10 @@ discard block |
||
399 | 449 | ); |
400 | 450 | // as the async_next column is used as a semaphore we only update it, |
401 | 451 | // if it is 0 (semaphore released) or older then 10min to recover from failed or crashed attempts |
402 | - if ($exists) $where = array('(async_next=0 OR async_next<'.(time()-600).')'); |
|
452 | + if ($exists) |
|
453 | + { |
|
454 | + $where = array('(async_next=0 OR async_next<'.(time()-600).')'); |
|
455 | + } |
|
403 | 456 | } |
404 | 457 | //echo "last_run=<pre>"; print_r($last_run); echo "</pre>\n"; |
405 | 458 | return $this->write($last_run, !!$exists, $where) > 0; |
@@ -410,7 +463,10 @@ discard block |
||
410 | 463 | */ |
411 | 464 | function check_run($run_by='') |
412 | 465 | { |
413 | - if ($run_by === 'fallback') flush(); |
|
466 | + if ($run_by === 'fallback') |
|
467 | + { |
|
468 | + flush(); |
|
469 | + } |
|
414 | 470 | |
415 | 471 | if (!$this->last_check_run(True,False,$run_by)) |
416 | 472 | { |
@@ -432,7 +488,10 @@ discard block |
||
432 | 488 | // unset all objects in $GLOBALS, which are created and used by ExecMethod, as they can contain user-data |
433 | 489 | foreach($GLOBALS as $name => $value) |
434 | 490 | { |
435 | - if ($name !== 'egw' && is_object($value)) unset($GLOBALS[$name]); |
|
491 | + if ($name !== 'egw' && is_object($value)) |
|
492 | + { |
|
493 | + unset($GLOBALS[$name]); |
|
494 | + } |
|
436 | 495 | } |
437 | 496 | $domain = $GLOBALS['egw_info']['user']['domain']; |
438 | 497 | $lang = $GLOBALS['egw_info']['user']['preferences']['common']['lang']; |
@@ -465,7 +524,10 @@ discard block |
||
465 | 524 | $job['data'] += array_diff_key($job,array('data' => false)); |
466 | 525 | } |
467 | 526 | |
468 | - if ($this->debug) error_log(__METHOD__."() processing job ".array2string($job)); |
|
527 | + if ($this->debug) |
|
528 | + { |
|
529 | + error_log(__METHOD__."() processing job ".array2string($job)); |
|
530 | + } |
|
469 | 531 | |
470 | 532 | // purge keeped jobs, if they are due |
471 | 533 | if (is_array($job['data']) && !empty($job['data']['keep_time'])) |
@@ -479,10 +541,16 @@ discard block |
||
479 | 541 | if ($job['next'] < $job['data']['keep_time']) |
480 | 542 | { |
481 | 543 | $job['next'] = $job['data']['keep_time']; |
482 | - if ($this->debug) error_log(__METHOD__."() setting next to keep_time (".date('Y-m-d H:i:s', $job['data']['keep_time']).') for job '.array2string($job)); |
|
544 | + if ($this->debug) |
|
545 | + { |
|
546 | + error_log(__METHOD__."() setting next to keep_time (".date('Y-m-d H:i:s', $job['data']['keep_time']).') for job '.array2string($job)); |
|
547 | + } |
|
483 | 548 | $this->write($job, True); |
484 | 549 | } |
485 | - if ($this->debug) error_log(__METHOD__."() keeping job ".array2string($job)); |
|
550 | + if ($this->debug) |
|
551 | + { |
|
552 | + error_log(__METHOD__."() keeping job ".array2string($job)); |
|
553 | + } |
|
486 | 554 | continue; |
487 | 555 | } |
488 | 556 | |
@@ -494,7 +562,10 @@ discard block |
||
494 | 562 | if (!$job['next']) |
495 | 563 | { |
496 | 564 | $job['next'] = $job['data']['keep_time'] = time() + ((int)$job['data']['keep'] > 1 ? $job['data']['keep'] : self::DEFAULT_KEEP_TIME); |
497 | - if ($this->debug) error_log(__METHOD__."() setting keep_time to ".date('Y-m-d H:i:s', $job['data']['keep_time']).' for job '.array2string($job)); |
|
565 | + if ($this->debug) |
|
566 | + { |
|
567 | + error_log(__METHOD__."() setting keep_time to ".date('Y-m-d H:i:s', $job['data']['keep_time']).' for job '.array2string($job)); |
|
568 | + } |
|
498 | 569 | } |
499 | 570 | $this->write($job, True); |
500 | 571 | } |
@@ -504,7 +575,10 @@ discard block |
||
504 | 575 | } |
505 | 576 | try |
506 | 577 | { |
507 | - if ($this->debug) error_log(__METHOD__."() running job ".array2string($job)); |
|
578 | + if ($this->debug) |
|
579 | + { |
|
580 | + error_log(__METHOD__."() running job ".array2string($job)); |
|
581 | + } |
|
508 | 582 | ExecMethod($job['method'],$job['data']); |
509 | 583 | } |
510 | 584 | catch(Exception $e) |
@@ -532,7 +606,10 @@ discard block |
||
532 | 606 | */ |
533 | 607 | function read($id=0,$cols='*',$offset=False,$append='ORDER BY async_next',$num_rows=0) |
534 | 608 | { |
535 | - if (!is_a($this->db, 'EGroupware\\Api\\Db')) return false; |
|
609 | + if (!is_a($this->db, 'EGroupware\\Api\\Db')) |
|
610 | + { |
|
611 | + return false; |
|
612 | + } |
|
536 | 613 | |
537 | 614 | if ($id === '%') |
538 | 615 | { |
@@ -585,9 +662,15 @@ discard block |
||
585 | 662 | */ |
586 | 663 | function write($job, $exists = False, $where=array()) |
587 | 664 | { |
588 | - if (!is_a($this->db, 'EGroupware\\Api\\Db')) return 0; |
|
665 | + if (!is_a($this->db, 'EGroupware\\Api\\Db')) |
|
666 | + { |
|
667 | + return 0; |
|
668 | + } |
|
589 | 669 | |
590 | - if (is_array($job['data']) && isset($job['data']['next']) && isset($job['next'])) $job['data']['next'] = $job['next']; |
|
670 | + if (is_array($job['data']) && isset($job['data']['next']) && isset($job['next'])) |
|
671 | + { |
|
672 | + $job['data']['next'] = $job['next']; |
|
673 | + } |
|
591 | 674 | $data = array( |
592 | 675 | 'async_next' => $job['next'], |
593 | 676 | 'async_times' => json_encode($job['times']), |
@@ -614,7 +697,10 @@ discard block |
||
614 | 697 | */ |
615 | 698 | function delete($id) |
616 | 699 | { |
617 | - if ($this->debug) error_log(__METHOD__."('$id') ".function_backtrace()); |
|
700 | + if ($this->debug) |
|
701 | + { |
|
702 | + error_log(__METHOD__."('$id') ".function_backtrace()); |
|
703 | + } |
|
618 | 704 | $this->db->delete($this->db_table,array('async_id' => $id),__LINE__,__FILE__); |
619 | 705 | |
620 | 706 | return $this->db->affected_rows(); |
@@ -653,9 +739,12 @@ discard block |
||
653 | 739 | { |
654 | 740 | echo '<p>'.lang('%1 is not executable by the webserver !!!',$this->$name)."</p>\n"; |
655 | 741 | $perms = fileperms($this->$name); |
656 | - if (!($perms & 0x0001) && ($perms & 0x0008) && function_exists('posix_getuid')) // only executable by group |
|
742 | + if (!($perms & 0x0001) && ($perms & 0x0008) && function_exists('posix_getuid')) |
|
743 | + { |
|
744 | + // only executable by group |
|
657 | 745 | { |
658 | 746 | $group = posix_getgrgid(filegroup($this->$name)); |
747 | + } |
|
659 | 748 | $webserver = posix_getpwuid(posix_getuid ()); |
660 | 749 | echo '<p>'.lang("You need to add the webserver user '%1' to the group '%2'.",$webserver['name'],$group['name'])."</p>\n"; } |
661 | 750 | } |
@@ -675,10 +764,13 @@ discard block |
||
675 | 764 | } |
676 | 765 | //echo "<p>$name = '".$this->$name."'</p>\n"; |
677 | 766 | } |
678 | - if ($this->php5[0] == '/') // we found a php5 binary |
|
767 | + if ($this->php5[0] == '/') |
|
768 | + { |
|
769 | + // we found a php5 binary |
|
679 | 770 | { |
680 | 771 | $this->php = $this->php5; |
681 | 772 | } |
773 | + } |
|
682 | 774 | } |
683 | 775 | } |
684 | 776 | |
@@ -695,7 +787,8 @@ discard block |
||
695 | 787 | */ |
696 | 788 | function installed(array &$other_cronlines=array()) |
697 | 789 | { |
698 | - if ($this->only_fallback) { |
|
790 | + if ($this->only_fallback) |
|
791 | + { |
|
699 | 792 | return 0; |
700 | 793 | } |
701 | 794 | $this->find_binarys(); |
@@ -712,7 +805,10 @@ discard block |
||
712 | 805 | $n = 0; |
713 | 806 | while ($line = fgets($crontab,256)) |
714 | 807 | { |
715 | - if ($this->debug) error_log(__METHOD__.'() line '.++$n.": $line"); |
|
808 | + if ($this->debug) |
|
809 | + { |
|
810 | + error_log(__METHOD__.'() line '.++$n.": $line"); |
|
811 | + } |
|
716 | 812 | $parts = explode(' ',$line,6); |
717 | 813 | |
718 | 814 | if ($line{0} == '#' || count($parts) < 6 || ($parts[5]{0} != '/' && substr($parts[5],0,3) != 'php')) |
@@ -756,7 +852,8 @@ discard block |
||
756 | 852 | */ |
757 | 853 | function install($times) |
758 | 854 | { |
759 | - if ($this->only_fallback && $times !== False) { |
|
855 | + if ($this->only_fallback && $times !== False) |
|
856 | + { |
|
760 | 857 | return 0; |
761 | 858 | } |
762 | 859 | $other_cronlines = array(); |
@@ -84,8 +84,8 @@ discard block |
||
84 | 84 | * check if users are supposed to change their password every x sdays, then check if password is of old age |
85 | 85 | * or the devil-admin reset the users password and forced the user to change his password on next login. |
86 | 86 | * |
87 | - * @param string& $message =null on return false: message why password needs to be changed |
|
88 | - * @return boolean true: all good, false: password change required, null: password expires in N days |
|
87 | + * @param string $message =null on return false: message why password needs to be changed |
|
88 | + * @return boolean|null true: all good, false: password change required, null: password expires in N days |
|
89 | 89 | */ |
90 | 90 | static function check_password_change(&$message=null) |
91 | 91 | { |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | * |
295 | 295 | * uses the encryption type set in setup and calls the appropriate encryption functions |
296 | 296 | * |
297 | - * @param $password password to encrypt |
|
297 | + * @param string $password password to encrypt |
|
298 | 298 | */ |
299 | 299 | static function encrypt_password($password,$sql=False) |
300 | 300 | { |
@@ -406,6 +406,7 @@ discard block |
||
406 | 406 | * @param string $form_val user input value for comparison |
407 | 407 | * @param string $db_val stored value / hash (from database) |
408 | 408 | * @param string &$type detected crypt type on return |
409 | + * @param string $type |
|
409 | 410 | * @return boolean True on successful comparison |
410 | 411 | */ |
411 | 412 | static function crypt_compare($form_val, $db_val, &$type) |
@@ -618,7 +619,7 @@ discard block |
||
618 | 619 | * @param string $forbid_name =null if "yes" username or full-name split by delimiters AND longer then 3 chars are |
619 | 620 | * forbidden to be included in password, default to whatever set in config for "passwd_forbid_name" |
620 | 621 | * @param array|int $account =null array with account_lid and account_fullname or account_id for $forbid_name check |
621 | - * @return mixed false if password is considered "safe" (or no requirements) or a string $message if "unsafe" |
|
622 | + * @return string|false false if password is considered "safe" (or no requirements) or a string $message if "unsafe" |
|
622 | 623 | */ |
623 | 624 | static function crackcheck($passwd, $reqstrength=null, $minlength=null, $forbid_name=null, $account=null) |
624 | 625 | { |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | * @param string $db_val stored value / hash (from database) |
408 | 408 | * @param string &$type detected crypt type on return |
409 | 409 | * @return boolean True on successful comparison |
410 | - */ |
|
410 | + */ |
|
411 | 411 | static function crypt_compare($form_val, $db_val, &$type) |
412 | 412 | { |
413 | 413 | // detect type of hash by salt part of $db_val |
@@ -706,7 +706,7 @@ discard block |
||
706 | 706 | * @param string $form_val user input value for comparison |
707 | 707 | * @param string $db_val stored value (from database) |
708 | 708 | * @return boolean True on successful comparison |
709 | - */ |
|
709 | + */ |
|
710 | 710 | static function smd5_compare($form_val,$db_val) |
711 | 711 | { |
712 | 712 | /* Start with the first char after {SMD5} */ |
@@ -728,7 +728,7 @@ discard block |
||
728 | 728 | * @param string $form_val user input value for comparison |
729 | 729 | * @param string $db_val stored value (from database) |
730 | 730 | * @return boolean True on successful comparison |
731 | - */ |
|
731 | + */ |
|
732 | 732 | static function sha_compare($form_val,$db_val) |
733 | 733 | { |
734 | 734 | /* Start with the first char after {SHA} */ |
@@ -745,7 +745,7 @@ discard block |
||
745 | 745 | * @param string $form_val user input value for comparison |
746 | 746 | * @param string $db_val stored value (from database) |
747 | 747 | * @return boolean True on successful comparison |
748 | - */ |
|
748 | + */ |
|
749 | 749 | static function ssha_compare($form_val,$db_val) |
750 | 750 | { |
751 | 751 | /* Start with the first char after {SSHA} */ |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | { |
21 | 21 | $GLOBALS['egw_info']['server']['auth_type'] = $GLOBALS['egw_info']['server']['auth_type_'.$GLOBALS['egw_info']['flags']['currentapp']]; |
22 | 22 | } |
23 | -if(empty($GLOBALS['egw_info']['server']['auth_type'])) |
|
23 | +if (empty($GLOBALS['egw_info']['server']['auth_type'])) |
|
24 | 24 | { |
25 | 25 | $GLOBALS['egw_info']['server']['auth_type'] = 'sql'; |
26 | 26 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @param Backend $type =null |
67 | 67 | */ |
68 | - static function backend($type=null) |
|
68 | + static function backend($type = null) |
|
69 | 69 | { |
70 | 70 | if (is_null($type)) $type = $GLOBALS['egw_info']['server']['auth_type']; |
71 | 71 | |
@@ -92,29 +92,29 @@ discard block |
||
92 | 92 | * @param string& $message =null on return false: message why password needs to be changed |
93 | 93 | * @return boolean true: all good, false: password change required, null: password expires in N days |
94 | 94 | */ |
95 | - static function check_password_change(&$message=null) |
|
95 | + static function check_password_change(&$message = null) |
|
96 | 96 | { |
97 | 97 | // dont check anything for anonymous sessions/ users that are flagged as anonymous |
98 | 98 | if (is_object($GLOBALS['egw']->session) && $GLOBALS['egw']->session->session_flags == 'A') return true; |
99 | 99 | |
100 | 100 | // some statics (and initialisation to make information and timecalculation a) more readable in conditions b) persistent per request |
101 | 101 | // if user has to be warned about an upcomming passwordchange, remember for the session, that he was informed |
102 | - static $UserKnowsAboutPwdChange=null; |
|
103 | - if (is_null($UserKnowsAboutPwdChange)) $UserKnowsAboutPwdChange =& Cache::getSession('phpgwapi','auth_UserKnowsAboutPwdChange'); |
|
102 | + static $UserKnowsAboutPwdChange = null; |
|
103 | + if (is_null($UserKnowsAboutPwdChange)) $UserKnowsAboutPwdChange = & Cache::getSession('phpgwapi', 'auth_UserKnowsAboutPwdChange'); |
|
104 | 104 | |
105 | 105 | // retrieve the timestamp regarding the last change of the password from auth system and store it with the session |
106 | - static $alpwchange_val=null; |
|
107 | - static $pwdTsChecked=null; |
|
106 | + static $alpwchange_val = null; |
|
107 | + static $pwdTsChecked = null; |
|
108 | 108 | if (is_null($pwdTsChecked) && is_null($alpwchange_val) || (string)$alpwchange_val === '0') |
109 | 109 | { |
110 | - $alpwchange_val =& Cache::getSession('phpgwapi','auth_alpwchange_val'); // set that one with the session stored value |
|
110 | + $alpwchange_val = & Cache::getSession('phpgwapi', 'auth_alpwchange_val'); // set that one with the session stored value |
|
111 | 111 | // initalize statics - better readability of conditions |
112 | 112 | if (is_null($alpwchange_val) || (string)$alpwchange_val === '0') |
113 | 113 | { |
114 | 114 | $backend = self::backend(); |
115 | 115 | // this may change behavior, as it should detect forced PasswordChanges from your Authentication System too. |
116 | 116 | // on the other side, if your auth system does not require an forcedPasswordChange, you will not be asked. |
117 | - if (method_exists($backend,'getLastPwdChange')) |
|
117 | + if (method_exists($backend, 'getLastPwdChange')) |
|
118 | 118 | { |
119 | 119 | $alpwchange_val = $backend->getLastPwdChange($GLOBALS['egw']->session->account_lid); |
120 | 120 | $pwdTsChecked = true; |
@@ -128,8 +128,8 @@ discard block |
||
128 | 128 | //error_log(__METHOD__.__LINE__.'#'.$alpwchange_val.'# is null:'.is_null($alpwchange_val).'# is empty:'.empty($alpwchange_val).'# is set:'.isset($alpwchange_val)); |
129 | 129 | } |
130 | 130 | } |
131 | - static $passwordAgeBorder=null; |
|
132 | - static $daysLeftUntilChangeReq=null; |
|
131 | + static $passwordAgeBorder = null; |
|
132 | + static $daysLeftUntilChangeReq = null; |
|
133 | 133 | |
134 | 134 | // if neither timestamp isset return true, nothing to do (exept this means the password is too old) |
135 | 135 | if (is_null($alpwchange_val) && |
@@ -139,15 +139,15 @@ discard block |
||
139 | 139 | } |
140 | 140 | if (is_null($passwordAgeBorder) && $GLOBALS['egw_info']['server']['change_pwd_every_x_days']) |
141 | 141 | { |
142 | - $passwordAgeBorder = (DateTime::to('now','ts')-($GLOBALS['egw_info']['server']['change_pwd_every_x_days']*86400)); |
|
142 | + $passwordAgeBorder = (DateTime::to('now', 'ts') - ($GLOBALS['egw_info']['server']['change_pwd_every_x_days'] * 86400)); |
|
143 | 143 | } |
144 | 144 | if (is_null($daysLeftUntilChangeReq) && $GLOBALS['egw_info']['server']['warn_about_upcoming_pwd_change']) |
145 | 145 | { |
146 | 146 | // maxage - passwordage = days left until change is required |
147 | - $daysLeftUntilChangeReq = ($GLOBALS['egw_info']['server']['change_pwd_every_x_days'] - ((DateTime::to('now','ts')-($alpwchange_val?$alpwchange_val:0))/86400)); |
|
147 | + $daysLeftUntilChangeReq = ($GLOBALS['egw_info']['server']['change_pwd_every_x_days'] - ((DateTime::to('now', 'ts') - ($alpwchange_val ? $alpwchange_val : 0)) / 86400)); |
|
148 | 148 | } |
149 | - if ($alpwchange_val == 0 || // admin requested password change |
|
150 | - $passwordAgeBorder > $alpwchange_val || // change password every N days policy requests change |
|
149 | + if ($alpwchange_val == 0 || // admin requested password change |
|
150 | + $passwordAgeBorder > $alpwchange_val || // change password every N days policy requests change |
|
151 | 151 | // user should be warned N days in advance about change and is not yet |
152 | 152 | $GLOBALS['egw_info']['server']['change_pwd_every_x_days'] && |
153 | 153 | $GLOBALS['egw_info']['user']['apps']['preferences'] && |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | error_log(__METHOD__.' Password of '.$GLOBALS['egw_info']['user']['account_lid'].' ('.$GLOBALS['egw_info']['user']['account_fullname'].') is of old age.'.array2string(array( |
165 | 165 | 'ts'=> $alpwchange_val, |
166 | 166 | 'date'=>DateTime::to($alpwchange_val)))); |
167 | - $message = lang('It has been more then %1 days since you changed your password',$GLOBALS['egw_info']['server']['change_pwd_every_x_days']); |
|
167 | + $message = lang('It has been more then %1 days since you changed your password', $GLOBALS['egw_info']['server']['change_pwd_every_x_days']); |
|
168 | 168 | } |
169 | 169 | else |
170 | 170 | { |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | { |
176 | 176 | $UserKnowsAboutPwdChange = true; |
177 | 177 | } |
178 | - $message = lang('Your password is about to expire in %1 days, you may change your password now',round($daysLeftUntilChangeReq)); |
|
178 | + $message = lang('Your password is about to expire in %1 days, you may change your password now', round($daysLeftUntilChangeReq)); |
|
179 | 179 | // user has no rights to change password --> do NOT warn, as only forced check ignores rights |
180 | 180 | if ($GLOBALS['egw']->acl->check('nopasswordchange', 1, 'preferences')) return true; |
181 | 181 | return null; |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | */ |
194 | 194 | function getLastPwdChange($username) |
195 | 195 | { |
196 | - if (method_exists($this->backend,'getLastPwdChange')) |
|
196 | + if (method_exists($this->backend, 'getLastPwdChange')) |
|
197 | 197 | { |
198 | 198 | return $this->backend->getLastPwdChange($username); |
199 | 199 | } |
@@ -208,9 +208,9 @@ discard block |
||
208 | 208 | * @param int $lastpwdchange must be a unixtimestamp |
209 | 209 | * @return boolean true if account_lastpwd_change successful changed, false otherwise |
210 | 210 | */ |
211 | - function setLastPwdChange($account_id=0, $passwd=NULL, $lastpwdchange=NULL) |
|
211 | + function setLastPwdChange($account_id = 0, $passwd = NULL, $lastpwdchange = NULL) |
|
212 | 212 | { |
213 | - if (method_exists($this->backend,'setLastPwdChange')) |
|
213 | + if (method_exists($this->backend, 'setLastPwdChange')) |
|
214 | 214 | { |
215 | 215 | return $this->backend->setLastPwdChange($account_id, $passwd, $lastpwdchange); |
216 | 216 | } |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | * @param string $passwd_type ='text' 'text' for cleartext passwords (default) |
226 | 226 | * @return boolean true if successful authenticated, false otherwise |
227 | 227 | */ |
228 | - function authenticate($username, $passwd, $passwd_type='text') |
|
228 | + function authenticate($username, $passwd, $passwd_type = 'text') |
|
229 | 229 | { |
230 | 230 | return $this->backend->authenticate($username, $passwd, $passwd_type); |
231 | 231 | } |
@@ -240,9 +240,9 @@ discard block |
||
240 | 240 | * @throws Exception from backends having extra requirements |
241 | 241 | * @return boolean true if password successful changed, false otherwise |
242 | 242 | */ |
243 | - function change_password($old_passwd, $new_passwd, $account_id=0) |
|
243 | + function change_password($old_passwd, $new_passwd, $account_id = 0) |
|
244 | 244 | { |
245 | - if (($err = self::crackcheck($new_passwd,null,null,null,$account_id))) |
|
245 | + if (($err = self::crackcheck($new_passwd, null, null, null, $account_id))) |
|
246 | 246 | { |
247 | 247 | throw new Exception\WrongUserinput($err); |
248 | 248 | } |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | // need to change current users password in session |
254 | 254 | Cache::setSession('phpgwapi', 'password', base64_encode($new_passwd)); |
255 | 255 | $GLOBALS['egw_info']['user']['passwd'] = $new_passwd; |
256 | - $GLOBALS['egw_info']['user']['account_lastpwd_change'] = DateTime::to('now','ts'); |
|
256 | + $GLOBALS['egw_info']['user']['account_lastpwd_change'] = DateTime::to('now', 'ts'); |
|
257 | 257 | // invalidate EGroupware session, as password is stored in egw_info in session |
258 | 258 | Egw::invalidate_session_cache(); |
259 | 259 | } |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | * @param string $new_passwd =null new password, default session password |
274 | 274 | * @param int $account_id =null account_id, default current user |
275 | 275 | */ |
276 | - static function changepwd($old_passwd, $new_passwd=null, $account_id=null) |
|
276 | + static function changepwd($old_passwd, $new_passwd = null, $account_id = null) |
|
277 | 277 | { |
278 | 278 | if (!isset($account_id)) $account_id = $GLOBALS['egw']->session->account_id; |
279 | 279 | if (!isset($new_passwd)) $new_passwd = $GLOBALS['egw']->session->passwd; |
@@ -285,9 +285,9 @@ discard block |
||
285 | 285 | 'old_passwd' => $old_passwd, |
286 | 286 | 'new_passwd' => $new_passwd, |
287 | 287 | ); |
288 | - Hooks::process($GLOBALS['hook_values']+array( |
|
288 | + Hooks::process($GLOBALS['hook_values'] + array( |
|
289 | 289 | 'location' => 'changepassword' |
290 | - ),False,True); // called for every app now, not only enabled ones) |
|
290 | + ), False, True); // called for every app now, not only enabled ones) |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | /** |
@@ -295,13 +295,13 @@ discard block |
||
295 | 295 | * |
296 | 296 | * @param $size int-size of random string to return |
297 | 297 | */ |
298 | - static function randomstring($size, $use_specialchars=false) |
|
298 | + static function randomstring($size, $use_specialchars = false) |
|
299 | 299 | { |
300 | 300 | $random_char = array( |
301 | - '0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f', |
|
302 | - 'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v', |
|
303 | - 'w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L', |
|
304 | - 'M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z' |
|
301 | + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', |
|
302 | + 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', |
|
303 | + 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', |
|
304 | + 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' |
|
305 | 305 | ); |
306 | 306 | |
307 | 307 | // we need special chars |
@@ -314,9 +314,9 @@ discard block |
||
314 | 314 | $func = function_exists('random_int') ? 'random_int' : 'mt_rand'; |
315 | 315 | |
316 | 316 | $s = ''; |
317 | - for ($i=0; $i < $size; $i++) |
|
317 | + for ($i = 0; $i < $size; $i++) |
|
318 | 318 | { |
319 | - $s .= $random_char[$func(0, count($random_char)-1)]; |
|
319 | + $s .= $random_char[$func(0, count($random_char) - 1)]; |
|
320 | 320 | } |
321 | 321 | return $s; |
322 | 322 | } |
@@ -328,9 +328,9 @@ discard block |
||
328 | 328 | * |
329 | 329 | * @param $password password to encrypt |
330 | 330 | */ |
331 | - static function encrypt_password($password,$sql=False) |
|
331 | + static function encrypt_password($password, $sql = False) |
|
332 | 332 | { |
333 | - if($sql) |
|
333 | + if ($sql) |
|
334 | 334 | { |
335 | 335 | return self::encrypt_sql($password); |
336 | 336 | } |
@@ -349,21 +349,21 @@ discard block |
||
349 | 349 | * @param string &$type =null on return detected type of hash |
350 | 350 | * @return boolean |
351 | 351 | */ |
352 | - static function compare_password($cleartext, $encrypted, $type_in, $username='', &$type=null) |
|
352 | + static function compare_password($cleartext, $encrypted, $type_in, $username = '', &$type = null) |
|
353 | 353 | { |
354 | 354 | // allow to specify the hash type to prefix the hash, to easy migrate passwords from ldap |
355 | 355 | $type = $type_in; |
356 | 356 | $saved_enc = $encrypted; |
357 | 357 | $matches = null; |
358 | - if (preg_match('/^\\{([a-z_5]+)\\}(.+)$/i',$encrypted,$matches)) |
|
358 | + if (preg_match('/^\\{([a-z_5]+)\\}(.+)$/i', $encrypted, $matches)) |
|
359 | 359 | { |
360 | 360 | $type = strtolower($matches[1]); |
361 | 361 | $encrypted = $matches[2]; |
362 | 362 | |
363 | - switch($type) // some hashs are specially "packed" in ldap |
|
363 | + switch ($type) // some hashs are specially "packed" in ldap |
|
364 | 364 | { |
365 | 365 | case 'md5': |
366 | - $encrypted = implode('',unpack('H*',base64_decode($encrypted))); |
|
366 | + $encrypted = implode('', unpack('H*', base64_decode($encrypted))); |
|
367 | 367 | break; |
368 | 368 | case 'plain': |
369 | 369 | case 'crypt': |
@@ -374,24 +374,24 @@ discard block |
||
374 | 374 | break; |
375 | 375 | } |
376 | 376 | } |
377 | - elseif($encrypted[0] == '$') |
|
377 | + elseif ($encrypted[0] == '$') |
|
378 | 378 | { |
379 | 379 | $type = 'crypt'; |
380 | 380 | } |
381 | 381 | |
382 | - switch($type) |
|
382 | + switch ($type) |
|
383 | 383 | { |
384 | 384 | case 'plain': |
385 | 385 | $ret = $cleartext === $encrypted; |
386 | 386 | break; |
387 | 387 | case 'smd5': |
388 | - $ret = self::smd5_compare($cleartext,$encrypted); |
|
388 | + $ret = self::smd5_compare($cleartext, $encrypted); |
|
389 | 389 | break; |
390 | 390 | case 'sha': |
391 | - $ret = self::sha_compare($cleartext,$encrypted); |
|
391 | + $ret = self::sha_compare($cleartext, $encrypted); |
|
392 | 392 | break; |
393 | 393 | case 'ssha': |
394 | - $ret = self::ssha_compare($cleartext,$encrypted); |
|
394 | + $ret = self::ssha_compare($cleartext, $encrypted); |
|
395 | 395 | break; |
396 | 396 | case 'crypt': |
397 | 397 | case 'des': |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | $ret = self::crypt_compare($cleartext, $encrypted, $type); |
405 | 405 | break; |
406 | 406 | case 'md5_hmac': |
407 | - $ret = self::md5_hmac_compare($cleartext,$encrypted,$username); |
|
407 | + $ret = self::md5_hmac_compare($cleartext, $encrypted, $username); |
|
408 | 408 | break; |
409 | 409 | default: |
410 | 410 | $type = 'md5'; |
@@ -427,9 +427,9 @@ discard block |
||
427 | 427 | 'ext_crypt' => array('CRYPT_EXT_DES', '_J9..', 4, ''), |
428 | 428 | 'md5_crypt' => array('CRYPT_MD5', '$1$', 8, '$'), |
429 | 429 | //'old_blowfish_crypt' => array('CRYPT_BLOWFISH', '$2$', 13, ''), // old blowfish hash not in line with php.net docu, but could be in use |
430 | - 'blowfish_crypt' => array('CRYPT_BLOWFISH', '$2a$12$', 22, ''), // $2a$12$ = 2^12 = 4096 rounds |
|
431 | - 'sha256_crypt' => array('CRYPT_SHA256', '$5$', 16, '$'), // no "round=N$" --> default of 5000 rounds |
|
432 | - 'sha512_crypt' => array('CRYPT_SHA512', '$6$', 16, '$'), // no "round=N$" --> default of 5000 rounds |
|
430 | + 'blowfish_crypt' => array('CRYPT_BLOWFISH', '$2a$12$', 22, ''), // $2a$12$ = 2^12 = 4096 rounds |
|
431 | + 'sha256_crypt' => array('CRYPT_SHA256', '$5$', 16, '$'), // no "round=N$" --> default of 5000 rounds |
|
432 | + 'sha512_crypt' => array('CRYPT_SHA512', '$6$', 16, '$'), // no "round=N$" --> default of 5000 rounds |
|
433 | 433 | ); |
434 | 434 | |
435 | 435 | /** |
@@ -444,17 +444,17 @@ discard block |
||
444 | 444 | { |
445 | 445 | // detect type of hash by salt part of $db_val |
446 | 446 | list($first, $dollar, $salt, $salt2) = explode('$', $db_val); |
447 | - foreach(self::$crypt_params as $type => $params) |
|
447 | + foreach (self::$crypt_params as $type => $params) |
|
448 | 448 | { |
449 | 449 | list(,$prefix, $random, $postfix) = $params; |
450 | 450 | list(,$d) = explode('$', $prefix); |
451 | 451 | if ($dollar === $d || !$dollar && ($first[0] === $prefix[0] || $first[0] !== '_' && !$prefix)) |
452 | 452 | { |
453 | - $len = !$postfix ? strlen($prefix)+$random : strlen($prefix.$salt.$postfix); |
|
453 | + $len = !$postfix ? strlen($prefix) + $random : strlen($prefix.$salt.$postfix); |
|
454 | 454 | // sha(256|512) might contain options, explicit $rounds=N$ prefix in salt |
455 | 455 | if (($type == 'sha256_crypt' || $type == 'sha512_crypt') && substr($salt, 0, 7) === 'rounds=') |
456 | 456 | { |
457 | - $len += strlen($salt2)+1; |
|
457 | + $len += strlen($salt2) + 1; |
|
458 | 458 | } |
459 | 459 | break; |
460 | 460 | } |
@@ -476,12 +476,12 @@ discard block |
||
476 | 476 | * @param string $type =null default to $GLOBALS['egw_info']['server']['ldap_encryption_type'] |
477 | 477 | * @return string |
478 | 478 | */ |
479 | - static function encrypt_ldap($password, $type=null) |
|
479 | + static function encrypt_ldap($password, $type = null) |
|
480 | 480 | { |
481 | 481 | if (is_null($type)) $type = $GLOBALS['egw_info']['server']['ldap_encryption_type']; |
482 | 482 | |
483 | 483 | $salt = ''; |
484 | - switch(strtolower($type)) |
|
484 | + switch (strtolower($type)) |
|
485 | 485 | { |
486 | 486 | default: // eg. setup >> config never saved |
487 | 487 | case 'des': |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | case 'md5_crypt': |
496 | 496 | case 'ext_crypt': |
497 | 497 | list($const, $prefix, $len, $postfix) = self::$crypt_params[$type]; |
498 | - if(defined($const) && constant($const) == 1) |
|
498 | + if (defined($const) && constant($const) == 1) |
|
499 | 499 | { |
500 | 500 | $salt = $prefix.self::randomstring($len).$postfix; |
501 | 501 | $e_password = '{crypt}'.crypt($password, $salt); |
@@ -508,20 +508,20 @@ discard block |
||
508 | 508 | /* New method taken from the openldap-software list as recommended by |
509 | 509 | * Kervin L. Pierre" <[email protected]> |
510 | 510 | */ |
511 | - $e_password = '{md5}' . base64_encode(pack("H*",md5($password))); |
|
511 | + $e_password = '{md5}'.base64_encode(pack("H*", md5($password))); |
|
512 | 512 | break; |
513 | 513 | case 'smd5': |
514 | 514 | $salt = self::randomstring(16); |
515 | - $hash = md5($password . $salt, true); |
|
516 | - $e_password = '{SMD5}' . base64_encode($hash . $salt); |
|
515 | + $hash = md5($password.$salt, true); |
|
516 | + $e_password = '{SMD5}'.base64_encode($hash.$salt); |
|
517 | 517 | break; |
518 | 518 | case 'sha': |
519 | - $e_password = '{SHA}' . base64_encode(sha1($password,true)); |
|
519 | + $e_password = '{SHA}'.base64_encode(sha1($password, true)); |
|
520 | 520 | break; |
521 | 521 | case 'ssha': |
522 | 522 | $salt = self::randomstring(16); |
523 | - $hash = sha1($password . $salt, true); |
|
524 | - $e_password = '{SSHA}' . base64_encode($hash . $salt); |
|
523 | + $hash = sha1($password.$salt, true); |
|
524 | + $e_password = '{SSHA}'.base64_encode($hash.$salt); |
|
525 | 525 | break; |
526 | 526 | case 'plain': |
527 | 527 | // if plain no type is prepended |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | * @param string $type =null default $GLOBALS['egw_info']['server']['sql_encryption_type'], if valid otherwise blowfish_crypt |
540 | 540 | * @return string hash |
541 | 541 | */ |
542 | - static function encrypt_sql($password, $type=null) |
|
542 | + static function encrypt_sql($password, $type = null) |
|
543 | 543 | { |
544 | 544 | /* Grab configured type, or default to md5() (old method) */ |
545 | 545 | if (is_null($type)) |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | $type = @$GLOBALS['egw_info']['server']['sql_encryption_type'] ? |
548 | 548 | strtolower($GLOBALS['egw_info']['server']['sql_encryption_type']) : 'md5'; |
549 | 549 | } |
550 | - switch($type) |
|
550 | + switch ($type) |
|
551 | 551 | { |
552 | 552 | case 'plain': |
553 | 553 | // since md5 is the default, type plain must be prepended, for eGroupware to understand |
@@ -587,28 +587,28 @@ discard block |
||
587 | 587 | * @param string &$securest =null on return securest available hash |
588 | 588 | * @return array hash => label |
589 | 589 | */ |
590 | - public static function passwdhashes(&$securest=null) |
|
590 | + public static function passwdhashes(&$securest = null) |
|
591 | 591 | { |
592 | 592 | $hashes = array(); |
593 | 593 | |
594 | 594 | /* Check for available crypt methods based on what is defined by php */ |
595 | - if(defined('CRYPT_BLOWFISH') && CRYPT_BLOWFISH == 1) |
|
595 | + if (defined('CRYPT_BLOWFISH') && CRYPT_BLOWFISH == 1) |
|
596 | 596 | { |
597 | 597 | $hashes['blowfish_crypt'] = 'blowfish_crypt'; |
598 | 598 | } |
599 | - if(defined('CRYPT_SHA512') && CRYPT_SHA512 == 1) |
|
599 | + if (defined('CRYPT_SHA512') && CRYPT_SHA512 == 1) |
|
600 | 600 | { |
601 | 601 | $hashes['sha512_crypt'] = 'sha512_crypt'; |
602 | 602 | } |
603 | - if(defined('CRYPT_SHA256') && CRYPT_SHA256 == 1) |
|
603 | + if (defined('CRYPT_SHA256') && CRYPT_SHA256 == 1) |
|
604 | 604 | { |
605 | 605 | $hashes['sha256_crypt'] = 'sha256_crypt'; |
606 | 606 | } |
607 | - if(defined('CRYPT_MD5') && CRYPT_MD5 == 1) |
|
607 | + if (defined('CRYPT_MD5') && CRYPT_MD5 == 1) |
|
608 | 608 | { |
609 | 609 | $hashes['md5_crypt'] = 'md5_crypt'; |
610 | 610 | } |
611 | - if(defined('CRYPT_EXT_DES') && CRYPT_EXT_DES == 1) |
|
611 | + if (defined('CRYPT_EXT_DES') && CRYPT_EXT_DES == 1) |
|
612 | 612 | { |
613 | 613 | $hashes['ext_crypt'] = 'ext_crypt'; |
614 | 614 | } |
@@ -617,7 +617,7 @@ discard block |
||
617 | 617 | 'smd5' => 'smd5', |
618 | 618 | 'sha' => 'sha', |
619 | 619 | ); |
620 | - if(@defined('CRYPT_STD_DES') && CRYPT_STD_DES == 1) |
|
620 | + if (@defined('CRYPT_STD_DES') && CRYPT_STD_DES == 1) |
|
621 | 621 | { |
622 | 622 | $hashes['crypt'] = 'crypt'; |
623 | 623 | } |
@@ -650,7 +650,7 @@ discard block |
||
650 | 650 | * @param array|int $account =null array with account_lid and account_fullname or account_id for $forbid_name check |
651 | 651 | * @return mixed false if password is considered "safe" (or no requirements) or a string $message if "unsafe" |
652 | 652 | */ |
653 | - static function crackcheck($passwd, $reqstrength=null, $minlength=null, $forbid_name=null, $account=null) |
|
653 | + static function crackcheck($passwd, $reqstrength = null, $minlength = null, $forbid_name = null, $account = null) |
|
654 | 654 | { |
655 | 655 | if (!isset($reqstrength)) $reqstrength = $GLOBALS['egw_info']['server']['force_pwd_strength']; |
656 | 656 | if (!isset($minlength)) $minlength = $GLOBALS['egw_info']['server']['force_pwd_length']; |
@@ -664,11 +664,11 @@ discard block |
||
664 | 664 | { |
665 | 665 | if (!isset($reqstrength) || $reqstrength == 5) |
666 | 666 | { |
667 | - Config::save_value('force_pwd_strength', $reqstrength=4, 'phpgwapi'); |
|
667 | + Config::save_value('force_pwd_strength', $reqstrength = 4, 'phpgwapi'); |
|
668 | 668 | } |
669 | 669 | if (!isset($minlength)) |
670 | 670 | { |
671 | - Config::save_value('force_pwd_length', $minlength=7, 'phpgwapi'); |
|
671 | + Config::save_value('force_pwd_length', $minlength = 7, 'phpgwapi'); |
|
672 | 672 | } |
673 | 673 | Config::save_value('check_save_passwd', null, 'phpgwapi'); |
674 | 674 | } |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | throw new Exception\WrongParameter('crackcheck(..., forbid_name=true, account) requires account-data!'); |
688 | 688 | } |
689 | 689 | $parts = preg_split("/[,._ \t0-9-]+/", $account['account_fullname'].','.$account['account_lid']); |
690 | - foreach($parts as $part) |
|
690 | + foreach ($parts as $part) |
|
691 | 691 | { |
692 | 692 | if (strlen($part) > 2 && stripos($passwd, $part) !== false) |
693 | 693 | { |
@@ -700,15 +700,15 @@ discard block |
||
700 | 700 | if ($reqstrength) |
701 | 701 | { |
702 | 702 | $missing = array(); |
703 | - if (!preg_match('/(.*\d.*){'. ($non=1). ',}/',$passwd)) |
|
703 | + if (!preg_match('/(.*\d.*){'.($non = 1).',}/', $passwd)) |
|
704 | 704 | { |
705 | 705 | $missing[] = lang('numbers'); |
706 | 706 | } |
707 | - if (!preg_match('/(.*[[:upper:]].*){'. ($nou=1). ',}/',$passwd)) |
|
707 | + if (!preg_match('/(.*[[:upper:]].*){'.($nou = 1).',}/', $passwd)) |
|
708 | 708 | { |
709 | 709 | $missing[] = lang('uppercase letters'); |
710 | 710 | } |
711 | - if (!preg_match('/(.*[[:lower:]].*){'. ($nol=1). ',}/',$passwd)) |
|
711 | + if (!preg_match('/(.*[[:lower:]].*){'.($nol = 1).',}/', $passwd)) |
|
712 | 712 | { |
713 | 713 | $missing[] = lang('lowercase letters'); |
714 | 714 | } |
@@ -719,7 +719,7 @@ discard block |
||
719 | 719 | if (4 - count($missing) < $reqstrength) |
720 | 720 | { |
721 | 721 | $errors[] = lang('password contains only %1 of required %2 character classes: no %3', |
722 | - 4-count($missing), $reqstrength, implode(', ', $missing)); |
|
722 | + 4 - count($missing), $reqstrength, implode(', ', $missing)); |
|
723 | 723 | } |
724 | 724 | } |
725 | 725 | if ($errors) |
@@ -737,19 +737,19 @@ discard block |
||
737 | 737 | * @param string $db_val stored value (from database) |
738 | 738 | * @return boolean True on successful comparison |
739 | 739 | */ |
740 | - static function smd5_compare($form_val,$db_val) |
|
740 | + static function smd5_compare($form_val, $db_val) |
|
741 | 741 | { |
742 | 742 | /* Start with the first char after {SMD5} */ |
743 | - $hash = base64_decode(substr($db_val,6)); |
|
743 | + $hash = base64_decode(substr($db_val, 6)); |
|
744 | 744 | |
745 | 745 | /* SMD5 hashes are 16 bytes long */ |
746 | - $orig_hash = cut_bytes($hash, 0, 16); // binary string need to use cut_bytes, not mb_substr(,,'utf-8')! |
|
746 | + $orig_hash = cut_bytes($hash, 0, 16); // binary string need to use cut_bytes, not mb_substr(,,'utf-8')! |
|
747 | 747 | $salt = cut_bytes($hash, 16); |
748 | 748 | |
749 | - $new_hash = md5($form_val . $salt,true); |
|
749 | + $new_hash = md5($form_val.$salt, true); |
|
750 | 750 | //echo '<br> DB: ' . base64_encode($orig_hash) . '<br>FORM: ' . base64_encode($new_hash); |
751 | 751 | |
752 | - return strcmp($orig_hash,$new_hash) == 0; |
|
752 | + return strcmp($orig_hash, $new_hash) == 0; |
|
753 | 753 | } |
754 | 754 | |
755 | 755 | /** |
@@ -759,14 +759,14 @@ discard block |
||
759 | 759 | * @param string $db_val stored value (from database) |
760 | 760 | * @return boolean True on successful comparison |
761 | 761 | */ |
762 | - static function sha_compare($form_val,$db_val) |
|
762 | + static function sha_compare($form_val, $db_val) |
|
763 | 763 | { |
764 | 764 | /* Start with the first char after {SHA} */ |
765 | - $hash = base64_decode(substr($db_val,5)); |
|
766 | - $new_hash = sha1($form_val,true); |
|
765 | + $hash = base64_decode(substr($db_val, 5)); |
|
766 | + $new_hash = sha1($form_val, true); |
|
767 | 767 | //echo '<br> DB: ' . base64_encode($orig_hash) . '<br>FORM: ' . base64_encode($new_hash); |
768 | 768 | |
769 | - return strcmp($hash,$new_hash) == 0; |
|
769 | + return strcmp($hash, $new_hash) == 0; |
|
770 | 770 | } |
771 | 771 | |
772 | 772 | /** |
@@ -776,18 +776,18 @@ discard block |
||
776 | 776 | * @param string $db_val stored value (from database) |
777 | 777 | * @return boolean True on successful comparison |
778 | 778 | */ |
779 | - static function ssha_compare($form_val,$db_val) |
|
779 | + static function ssha_compare($form_val, $db_val) |
|
780 | 780 | { |
781 | 781 | /* Start with the first char after {SSHA} */ |
782 | 782 | $hash = base64_decode(substr($db_val, 6)); |
783 | 783 | |
784 | 784 | // SHA-1 hashes are 160 bits long |
785 | - $orig_hash = cut_bytes($hash, 0, 20); // binary string need to use cut_bytes, not mb_substr(,,'utf-8')! |
|
785 | + $orig_hash = cut_bytes($hash, 0, 20); // binary string need to use cut_bytes, not mb_substr(,,'utf-8')! |
|
786 | 786 | $salt = cut_bytes($hash, 20); |
787 | - $new_hash = sha1($form_val . $salt,true); |
|
787 | + $new_hash = sha1($form_val.$salt, true); |
|
788 | 788 | |
789 | 789 | //error_log(__METHOD__."('$form_val', '$db_val') hash='$hash', orig_hash='$orig_hash', salt='$salt', new_hash='$new_hash' returning ".array2string(strcmp($orig_hash,$new_hash) == 0)); |
790 | - return strcmp($orig_hash,$new_hash) == 0; |
|
790 | + return strcmp($orig_hash, $new_hash) == 0; |
|
791 | 791 | } |
792 | 792 | |
793 | 793 | /** |
@@ -798,11 +798,11 @@ discard block |
||
798 | 798 | * @param string $_key key for md5_hmac-encryption (username for imported smf users) |
799 | 799 | * @return boolean True on successful comparison |
800 | 800 | */ |
801 | - static function md5_hmac_compare($form_val,$db_val,$_key) |
|
801 | + static function md5_hmac_compare($form_val, $db_val, $_key) |
|
802 | 802 | { |
803 | 803 | $key = str_pad(strlen($_key) <= 64 ? $_key : pack('H*', md5($_key)), 64, chr(0x00)); |
804 | - $md5_hmac = md5(($key ^ str_repeat(chr(0x5c), 64)) . pack('H*', md5(($key ^ str_repeat(chr(0x36), 64)). $form_val))); |
|
804 | + $md5_hmac = md5(($key^str_repeat(chr(0x5c), 64)).pack('H*', md5(($key^str_repeat(chr(0x36), 64)).$form_val))); |
|
805 | 805 | |
806 | - return strcmp($md5_hmac,$db_val) == 0; |
|
806 | + return strcmp($md5_hmac, $db_val) == 0; |
|
807 | 807 | } |
808 | 808 | } |
@@ -67,7 +67,10 @@ discard block |
||
67 | 67 | */ |
68 | 68 | static function backend($type=null) |
69 | 69 | { |
70 | - if (is_null($type)) $type = $GLOBALS['egw_info']['server']['auth_type']; |
|
70 | + if (is_null($type)) |
|
71 | + { |
|
72 | + $type = $GLOBALS['egw_info']['server']['auth_type']; |
|
73 | + } |
|
71 | 74 | |
72 | 75 | $backend_class = __CLASS__.'\\'.ucfirst($type); |
73 | 76 | |
@@ -95,12 +98,18 @@ discard block |
||
95 | 98 | static function check_password_change(&$message=null) |
96 | 99 | { |
97 | 100 | // dont check anything for anonymous sessions/ users that are flagged as anonymous |
98 | - if (is_object($GLOBALS['egw']->session) && $GLOBALS['egw']->session->session_flags == 'A') return true; |
|
101 | + if (is_object($GLOBALS['egw']->session) && $GLOBALS['egw']->session->session_flags == 'A') |
|
102 | + { |
|
103 | + return true; |
|
104 | + } |
|
99 | 105 | |
100 | 106 | // some statics (and initialisation to make information and timecalculation a) more readable in conditions b) persistent per request |
101 | 107 | // if user has to be warned about an upcomming passwordchange, remember for the session, that he was informed |
102 | 108 | static $UserKnowsAboutPwdChange=null; |
103 | - if (is_null($UserKnowsAboutPwdChange)) $UserKnowsAboutPwdChange =& Cache::getSession('phpgwapi','auth_UserKnowsAboutPwdChange'); |
|
109 | + if (is_null($UserKnowsAboutPwdChange)) |
|
110 | + { |
|
111 | + $UserKnowsAboutPwdChange =& Cache::getSession('phpgwapi','auth_UserKnowsAboutPwdChange'); |
|
112 | + } |
|
104 | 113 | |
105 | 114 | // retrieve the timestamp regarding the last change of the password from auth system and store it with the session |
106 | 115 | static $alpwchange_val=null; |
@@ -177,7 +186,10 @@ discard block |
||
177 | 186 | } |
178 | 187 | $message = lang('Your password is about to expire in %1 days, you may change your password now',round($daysLeftUntilChangeReq)); |
179 | 188 | // user has no rights to change password --> do NOT warn, as only forced check ignores rights |
180 | - if ($GLOBALS['egw']->acl->check('nopasswordchange', 1, 'preferences')) return true; |
|
189 | + if ($GLOBALS['egw']->acl->check('nopasswordchange', 1, 'preferences')) |
|
190 | + { |
|
191 | + return true; |
|
192 | + } |
|
181 | 193 | return null; |
182 | 194 | } |
183 | 195 | return false; |
@@ -275,8 +287,14 @@ discard block |
||
275 | 287 | */ |
276 | 288 | static function changepwd($old_passwd, $new_passwd=null, $account_id=null) |
277 | 289 | { |
278 | - if (!isset($account_id)) $account_id = $GLOBALS['egw']->session->account_id; |
|
279 | - if (!isset($new_passwd)) $new_passwd = $GLOBALS['egw']->session->passwd; |
|
290 | + if (!isset($account_id)) |
|
291 | + { |
|
292 | + $account_id = $GLOBALS['egw']->session->account_id; |
|
293 | + } |
|
294 | + if (!isset($new_passwd)) |
|
295 | + { |
|
296 | + $new_passwd = $GLOBALS['egw']->session->passwd; |
|
297 | + } |
|
280 | 298 | |
281 | 299 | // run changepwasswd hook |
282 | 300 | $GLOBALS['hook_values'] = array( |
@@ -478,7 +496,10 @@ discard block |
||
478 | 496 | */ |
479 | 497 | static function encrypt_ldap($password, $type=null) |
480 | 498 | { |
481 | - if (is_null($type)) $type = $GLOBALS['egw_info']['server']['ldap_encryption_type']; |
|
499 | + if (is_null($type)) |
|
500 | + { |
|
501 | + $type = $GLOBALS['egw_info']['server']['ldap_encryption_type']; |
|
502 | + } |
|
482 | 503 | |
483 | 504 | $salt = ''; |
484 | 505 | switch(strtolower($type)) |
@@ -652,9 +673,18 @@ discard block |
||
652 | 673 | */ |
653 | 674 | static function crackcheck($passwd, $reqstrength=null, $minlength=null, $forbid_name=null, $account=null) |
654 | 675 | { |
655 | - if (!isset($reqstrength)) $reqstrength = $GLOBALS['egw_info']['server']['force_pwd_strength']; |
|
656 | - if (!isset($minlength)) $minlength = $GLOBALS['egw_info']['server']['force_pwd_length']; |
|
657 | - if (!isset($forbid_name)) $forbid_name = $GLOBALS['egw_info']['server']['passwd_forbid_name']; |
|
676 | + if (!isset($reqstrength)) |
|
677 | + { |
|
678 | + $reqstrength = $GLOBALS['egw_info']['server']['force_pwd_strength']; |
|
679 | + } |
|
680 | + if (!isset($minlength)) |
|
681 | + { |
|
682 | + $minlength = $GLOBALS['egw_info']['server']['force_pwd_length']; |
|
683 | + } |
|
684 | + if (!isset($forbid_name)) |
|
685 | + { |
|
686 | + $forbid_name = $GLOBALS['egw_info']['server']['passwd_forbid_name']; |
|
687 | + } |
|
658 | 688 | |
659 | 689 | // load preferences translations, as changepassword get's called from admin too |
660 | 690 | Translation::add_app('preferences'); |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | * @param array &$options |
257 | 257 | * @param array &$files |
258 | 258 | * @param int $user account_id |
259 | - * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
259 | + * @return boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
260 | 260 | */ |
261 | 261 | function expand_property_report($path,&$options,&$files,$user) |
262 | 262 | { |
@@ -1191,7 +1191,7 @@ discard block |
||
1191 | 1191 | * Check if resource is a location |
1192 | 1192 | * |
1193 | 1193 | * @param array|int $resource |
1194 | - * @return boolean |
|
1194 | + * @return null|boolean |
|
1195 | 1195 | */ |
1196 | 1196 | public static function resource_is_location($resource) |
1197 | 1197 | { |
@@ -1470,7 +1470,6 @@ discard block |
||
1470 | 1470 | * Get proxy-groups for given user $account: users or groups who GRANT proxy rights to $account |
1471 | 1471 | * |
1472 | 1472 | * @param int $account who is the proxy |
1473 | - * @param string|array $app_proxys =null applications for which proxys should be added |
|
1474 | 1473 | * @return array with href props |
1475 | 1474 | */ |
1476 | 1475 | protected function get_resource_proxy_groups($account) |
@@ -1608,8 +1607,6 @@ discard block |
||
1608 | 1607 | /** |
1609 | 1608 | * Do propfind of /principals/ |
1610 | 1609 | * |
1611 | - * @param string $name name of group or empty |
|
1612 | - * @param string $rest name of rest of path behind group-name |
|
1613 | 1610 | * @param array $options |
1614 | 1611 | * @return array|string array with files or HTTP error code |
1615 | 1612 | */ |
@@ -1640,7 +1637,7 @@ discard block |
||
1640 | 1637 | * @param array &$options |
1641 | 1638 | * @param int $id |
1642 | 1639 | * @param int $user =null account_id |
1643 | - * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
1640 | + * @return boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
1644 | 1641 | */ |
1645 | 1642 | function get(&$options,$id,$user=null) |
1646 | 1643 | { |
@@ -1655,7 +1652,7 @@ discard block |
||
1655 | 1652 | * @param array &$options |
1656 | 1653 | * @param int $id |
1657 | 1654 | * @param int $user =null account_id of owner, default null |
1658 | - * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
1655 | + * @return boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
1659 | 1656 | */ |
1660 | 1657 | function put(&$options,$id,$user=null) |
1661 | 1658 | { |
@@ -1669,7 +1666,7 @@ discard block |
||
1669 | 1666 | * |
1670 | 1667 | * @param array &$options |
1671 | 1668 | * @param int $id |
1672 | - * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
1669 | + * @return boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
1673 | 1670 | */ |
1674 | 1671 | function delete(&$options,$id) |
1675 | 1672 | { |
@@ -1681,7 +1678,7 @@ discard block |
||
1681 | 1678 | /** |
1682 | 1679 | * Read an entry |
1683 | 1680 | * |
1684 | - * @param string|int $id |
|
1681 | + * @param integer $id |
|
1685 | 1682 | * @return array/boolean array with entry, false if no read rights, null if $id does not exist |
1686 | 1683 | */ |
1687 | 1684 | function read($id) |
@@ -1696,7 +1693,7 @@ discard block |
||
1696 | 1693 | * |
1697 | 1694 | * @param int $acl Api\Acl::READ, Api\Acl::EDIT or Api\Acl::DELETE |
1698 | 1695 | * @param array|int $entry entry-array or id |
1699 | - * @return boolean null if entry does not exist, false if no access, true if access permitted |
|
1696 | + * @return null|boolean null if entry does not exist, false if no access, true if access permitted |
|
1700 | 1697 | */ |
1701 | 1698 | function check_access($acl,$entry) |
1702 | 1699 | { |
@@ -1739,7 +1736,7 @@ discard block |
||
1739 | 1736 | * |
1740 | 1737 | * @param string $path path of collection |
1741 | 1738 | * @param int $user =null owner of the collection, default current user |
1742 | - * @return array with privileges |
|
1739 | + * @return string[] with privileges |
|
1743 | 1740 | */ |
1744 | 1741 | public function current_user_privileges($path, $user=null) |
1745 | 1742 | { |
@@ -88,19 +88,18 @@ discard block |
||
88 | 88 | * @param array $reports =null |
89 | 89 | * @return array Api\CalDAV::mkprop('supported-report-set', ...) |
90 | 90 | */ |
91 | - protected function supported_report_set($path, array $reports=null) |
|
91 | + protected function supported_report_set($path, array $reports = null) |
|
92 | 92 | { |
93 | - unset($path); // not used, but required by function signature |
|
93 | + unset($path); // not used, but required by function signature |
|
94 | 94 | |
95 | 95 | if (is_null($reports)) $reports = $this->supported_reports; |
96 | 96 | |
97 | 97 | $supported = array(); |
98 | - foreach($reports as $name => $data) |
|
98 | + foreach ($reports as $name => $data) |
|
99 | 99 | { |
100 | - $supported[$name] = Api\CalDAV::mkprop('supported-report',array( |
|
101 | - Api\CalDAV::mkprop('report',array( |
|
102 | - !$data['ns'] ? Api\CalDAV::mkprop($name, '') : |
|
103 | - Api\CalDAV::mkprop($data['ns'], $name, ''))))); |
|
100 | + $supported[$name] = Api\CalDAV::mkprop('supported-report', array( |
|
101 | + Api\CalDAV::mkprop('report', array( |
|
102 | + !$data['ns'] ? Api\CalDAV::mkprop($name, '') : Api\CalDAV::mkprop($data['ns'], $name, ''))))); |
|
104 | 103 | } |
105 | 104 | return $supported; |
106 | 105 | } |
@@ -114,7 +113,7 @@ discard block |
||
114 | 113 | * @param int $user account_id |
115 | 114 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
116 | 115 | */ |
117 | - function propfind($path,&$options,&$files,$user) |
|
116 | + function propfind($path, &$options, &$files, $user) |
|
118 | 117 | { |
119 | 118 | if (($report = isset($_GET['report']) ? $_GET['report'] : $options['root']['name']) && $report != 'propfind') |
120 | 119 | { |
@@ -126,7 +125,7 @@ discard block |
||
126 | 125 | $this->caldav->log(__METHOD__."('$path', ".array2string($options).",, $user) not implemented report, returning 501 Not Implemented"); |
127 | 126 | return '501 Not Implemented'; |
128 | 127 | } |
129 | - list(,,$type,$name,$rest) = explode('/',$path,5); |
|
128 | + list(,, $type, $name, $rest) = explode('/', $path, 5); |
|
130 | 129 | // /principals/users/$name/ |
131 | 130 | // /users/$name/calendar-proxy-read/ |
132 | 131 | // /users/$name/calendar-proxy-write/ |
@@ -135,19 +134,19 @@ discard block |
||
135 | 134 | // /locations/$resource/ |
136 | 135 | // /__uids__/$uid/.../ |
137 | 136 | |
138 | - switch($type) |
|
137 | + switch ($type) |
|
139 | 138 | { |
140 | 139 | case 'users': |
141 | - $files['files'] = $this->propfind_users($name,$rest,$options); |
|
140 | + $files['files'] = $this->propfind_users($name, $rest, $options); |
|
142 | 141 | break; |
143 | 142 | case 'groups': |
144 | - $files['files'] = $this->propfind_groups($name,$rest,$options); |
|
143 | + $files['files'] = $this->propfind_groups($name, $rest, $options); |
|
145 | 144 | break; |
146 | 145 | case 'resources': |
147 | - $files['files'] = $this->propfind_resources($name,$rest,$options,false); |
|
146 | + $files['files'] = $this->propfind_resources($name, $rest, $options, false); |
|
148 | 147 | break; |
149 | 148 | case 'locations': |
150 | - $files['files'] = $this->propfind_resources($name,$rest,$options,true); |
|
149 | + $files['files'] = $this->propfind_resources($name, $rest, $options, true); |
|
151 | 150 | break; |
152 | 151 | /*case '__uids__': |
153 | 152 | $files['files'] = $this->propfind_uids($name,$rest,$options); |
@@ -257,11 +256,11 @@ discard block |
||
257 | 256 | * @param int $user account_id |
258 | 257 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
259 | 258 | */ |
260 | - function expand_property_report($path,&$options,&$files,$user) |
|
259 | + function expand_property_report($path, &$options, &$files, $user) |
|
261 | 260 | { |
262 | 261 | //error_log(__METHOD__."('$path', ".array2string($options).",, $user)"); |
263 | 262 | $requested_props = $options['other']; |
264 | - while(($requested_prop = array_shift($requested_props))) |
|
263 | + while (($requested_prop = array_shift($requested_props))) |
|
265 | 264 | { |
266 | 265 | if ($requested_prop['name'] != 'property' || $requested_prop['depth'] != 1) continue; |
267 | 266 | |
@@ -269,11 +268,11 @@ discard block |
||
269 | 268 | $prop_name = $requested_prop['attrs']['name']; |
270 | 269 | $prop_path = $path; |
271 | 270 | // calendarserver has some special property-names for expansion |
272 | - switch($prop_name) |
|
271 | + switch ($prop_name) |
|
273 | 272 | { |
274 | 273 | case 'calendar-proxy-read-for': |
275 | 274 | case 'calendar-proxy-write-for': |
276 | - $prop_path = $path . substr($prop_name, 0, -4).'/'; |
|
275 | + $prop_path = $path.substr($prop_name, 0, -4).'/'; |
|
277 | 276 | $prop_name = 'group-member-set'; |
278 | 277 | $prop_ns = Api\CalDAV::DAV; |
279 | 278 | break; |
@@ -293,14 +292,14 @@ discard block |
||
293 | 292 | 'xmlns' => $prop_ns, |
294 | 293 | )); |
295 | 294 | $prop_files = array(); |
296 | - $this->caldav->options = $options; // also modify global variable |
|
295 | + $this->caldav->options = $options; // also modify global variable |
|
297 | 296 | if (empty($prop_name) || $this->propfind($prop_path, $options, $prop_files, $user) !== true) |
298 | 297 | { |
299 | 298 | $this->caldav->log('### NO expand-property report for '.$requested_prop['attrs']['name']); |
300 | 299 | continue; |
301 | 300 | } |
302 | 301 | // find prop to expand |
303 | - foreach($prop_files['files'][0]['props'] as $expand_prop) |
|
302 | + foreach ($prop_files['files'][0]['props'] as $expand_prop) |
|
304 | 303 | { |
305 | 304 | if ($expand_prop['name'] === $prop_name) break; |
306 | 305 | } |
@@ -314,7 +313,7 @@ discard block |
||
314 | 313 | // requested properties of each href are in depth=2 properties |
315 | 314 | // set them as regular propfind properties to $options['props'] |
316 | 315 | $options2 = array('props' => 'all'); |
317 | - while(($prop = array_shift($requested_props)) && $prop['depth'] >= 2) |
|
316 | + while (($prop = array_shift($requested_props)) && $prop['depth'] >= 2) |
|
318 | 317 | { |
319 | 318 | if ($prop['name'] == 'property' && $prop['depth'] == 2) |
320 | 319 | { |
@@ -330,10 +329,10 @@ discard block |
||
330 | 329 | } |
331 | 330 | // put back evtl. read top-level property |
332 | 331 | if ($prop && $prop['depth'] == 1) array_unshift($requested_props, $prop); |
333 | - $this->caldav->options = $options2; // also modify global variable |
|
332 | + $this->caldav->options = $options2; // also modify global variable |
|
334 | 333 | |
335 | 334 | // run regular profind to get requested 2.-level properties for each href |
336 | - foreach($expand_prop['val'] as $key => &$prop_val) |
|
335 | + foreach ($expand_prop['val'] as $key => &$prop_val) |
|
337 | 336 | { |
338 | 337 | list(,$expand_path) = explode($this->caldav->base_uri, $prop_val['val']); |
339 | 338 | //error_log(__METHOD__."('$path', ..., $user) calling propfind('$expand_path', ".array2string($options2).', '.array2string($prop_val).", $user)"); |
@@ -428,23 +427,23 @@ discard block |
||
428 | 427 | * @param int $user account_id |
429 | 428 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
430 | 429 | */ |
431 | - function principal_property_search_report($path,&$options,&$files,$user) |
|
430 | + function principal_property_search_report($path, &$options, &$files, $user) |
|
432 | 431 | { |
433 | 432 | //error_log(__METHOD__."('$path', ".array2string($options).",, $user)"); |
434 | 433 | |
435 | 434 | // cant find the test attribute to root principal-property-search element in WebDAV rfc, but iPhones use it ... |
436 | - $anyof = !empty($options['root']['attrs']['test']) && $options['root']['attrs']['test'] == 'anyof'; // "allof" (default) or "anyof" |
|
435 | + $anyof = !empty($options['root']['attrs']['test']) && $options['root']['attrs']['test'] == 'anyof'; // "allof" (default) or "anyof" |
|
437 | 436 | |
438 | 437 | // parse property-search prop(s) contained in $options['other'] |
439 | - foreach($options['other'] as $n => $prop) |
|
438 | + foreach ($options['other'] as $n => $prop) |
|
440 | 439 | { |
441 | - switch($prop['name']) |
|
440 | + switch ($prop['name']) |
|
442 | 441 | { |
443 | 442 | case 'apply-to-principal-collection-set': // optinal prop to apply search on principal-collection-set == '/principals/' |
444 | 443 | $path = '/principals/'; |
445 | 444 | break; |
446 | 445 | case 'property-search': |
447 | - $property_search = $n; // should be 1 |
|
446 | + $property_search = $n; // should be 1 |
|
448 | 447 | break; |
449 | 448 | case 'prop': |
450 | 449 | if (isset($property_search)) |
@@ -474,7 +473,7 @@ discard block |
||
474 | 473 | return '400 Bad Request'; |
475 | 474 | } |
476 | 475 | // make sure search property is included in toplevel props (can be missing and defaults to property-search/prop's) |
477 | - foreach($search_props as $prop) |
|
476 | + foreach ($search_props as $prop) |
|
478 | 477 | { |
479 | 478 | if (!$this->caldav->prop_requested($prop['name'], $prop['xmlns'])) |
480 | 479 | { |
@@ -487,7 +486,7 @@ discard block |
||
487 | 486 | // but interprets returning all principals (all have a matching calendar-home-set) as NOT supporting CalDAV scheduling |
488 | 487 | // --> search only current user's principal |
489 | 488 | if ($prop['name'] == 'calendar-home-set' && stripos($_SERVER['HTTP_USER_AGENT'], 'Lightning') !== false && |
490 | - substr($search_props[0]['match'],-13) == '/groupdav.php') |
|
489 | + substr($search_props[0]['match'], -13) == '/groupdav.php') |
|
491 | 490 | { |
492 | 491 | $path = '/principals/users/'.$GLOBALS['egw_info']['user']['account_lid'].'/'; |
493 | 492 | $this->caldav->log('Enabling hack for Lightning prior 1.1.1 for searching calendar-home-set matching "/groupdav.php": limiting search to '.$path); |
@@ -496,7 +495,7 @@ discard block |
||
496 | 495 | // check type attribute to limit search on a certain tree |
497 | 496 | if (isset($options['root']['attrs']['type'])) |
498 | 497 | { |
499 | - switch($options['root']['attrs']['type']) |
|
498 | + switch ($options['root']['attrs']['type']) |
|
500 | 499 | { |
501 | 500 | case 'INDIVIDUAL': |
502 | 501 | $path = '/principals/users/'; |
@@ -523,7 +522,7 @@ discard block |
||
523 | 522 | return $ret; |
524 | 523 | } |
525 | 524 | // now filter out not matching "files" |
526 | - foreach($files['files'] as $n => $resource) |
|
525 | + foreach ($files['files'] as $n => $resource) |
|
527 | 526 | { |
528 | 527 | if (count(explode('/', $resource['path'])) < 5) // hack to only return principals, not the collections itself |
529 | 528 | { |
@@ -532,18 +531,18 @@ discard block |
||
532 | 531 | } |
533 | 532 | // match with $search_props |
534 | 533 | $matches = 0; |
535 | - foreach($search_props as $search_prop) |
|
534 | + foreach ($search_props as $search_prop) |
|
536 | 535 | { |
537 | 536 | // search resource for $search_prop |
538 | - foreach($resource['props'] as $prop) |
|
537 | + foreach ($resource['props'] as $prop) |
|
539 | 538 | { |
540 | 539 | if ($prop['name'] === $search_prop['name']) break; |
541 | 540 | } |
542 | 541 | if ($prop['name'] === $search_prop['name']) // search_prop NOT found |
543 | 542 | { |
544 | - foreach((array)$prop['val'] as $value) |
|
543 | + foreach ((array)$prop['val'] as $value) |
|
545 | 544 | { |
546 | - if (is_array($value)) $value = $value['val']; // eg. href prop |
|
545 | + if (is_array($value)) $value = $value['val']; // eg. href prop |
|
547 | 546 | if (self::match($value, $search_prop['match'], $search_prop['match-type']) !== false) // prop does match |
548 | 547 | { |
549 | 548 | ++$matches; |
@@ -555,7 +554,7 @@ discard block |
||
555 | 554 | if ($anyof && $matches || $matches == count($search_props)) |
556 | 555 | { |
557 | 556 | //error_log("$resource[path]: anyof=$anyof, $matches matches --> keep"); |
558 | - continue 2; // enough matches --> keep |
|
557 | + continue 2; // enough matches --> keep |
|
559 | 558 | } |
560 | 559 | } |
561 | 560 | //error_log("$resource[path]: anyof=$anyof, $matches matches --> skip"); |
@@ -573,9 +572,9 @@ discard block |
||
573 | 572 | * @param string $match criteria/sub-string |
574 | 573 | * @param string $match_type ='contains' 'starts-with', 'ends-with' or 'equals' |
575 | 574 | */ |
576 | - private static function match($value, $match, $match_type='contains') |
|
575 | + private static function match($value, $match, $match_type = 'contains') |
|
577 | 576 | { |
578 | - switch($match_type) |
|
577 | + switch ($match_type) |
|
579 | 578 | { |
580 | 579 | case 'equals': |
581 | 580 | return $value === $match; |
@@ -645,9 +644,9 @@ discard block |
||
645 | 644 | * @param int $user account_id |
646 | 645 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
647 | 646 | */ |
648 | - function principal_search_property_set_report($path,&$options,&$files,$user) |
|
647 | + function principal_search_property_set_report($path, &$options, &$files, $user) |
|
649 | 648 | { |
650 | - unset($path, $options, $files, $user); // not used, but required by function signature |
|
649 | + unset($path, $options, $files, $user); // not used, but required by function signature |
|
651 | 650 | |
652 | 651 | static $search_props = array( |
653 | 652 | // from iOS iCal |
@@ -669,7 +668,7 @@ discard block |
||
669 | 668 | $xml->startDocument('1.0', 'UTF-8'); |
670 | 669 | $xml->startElementNs(null, 'principal-search-property-set', 'DAV:'); |
671 | 670 | |
672 | - foreach($search_props as $name => $data) |
|
671 | + foreach ($search_props as $name => $data) |
|
673 | 672 | { |
674 | 673 | $xml->startElement('principal-search-property'); |
675 | 674 | $xml->startElement('prop'); |
@@ -681,16 +680,16 @@ discard block |
||
681 | 680 | { |
682 | 681 | $xml->writeElement($name); |
683 | 682 | } |
684 | - $xml->endElement(); // prop |
|
683 | + $xml->endElement(); // prop |
|
685 | 684 | |
686 | 685 | $xml->startElement('description'); |
687 | 686 | $xml->writeAttribute('xml:lang', 'en'); |
688 | 687 | $xml->text(is_array($data) ? $data['description'] : $data); |
689 | - $xml->endElement(); // description |
|
688 | + $xml->endElement(); // description |
|
690 | 689 | |
691 | - $xml->endElement(); // principal-search-property |
|
690 | + $xml->endElement(); // principal-search-property |
|
692 | 691 | } |
693 | - $xml->endElement(); // principal-search-property-set |
|
692 | + $xml->endElement(); // principal-search-property-set |
|
694 | 693 | $xml->endDocument(); |
695 | 694 | echo $xml->outputMemory(); |
696 | 695 | |
@@ -725,7 +724,7 @@ discard block |
||
725 | 724 | * @param int $user account_id |
726 | 725 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
727 | 726 | */ |
728 | - function acl_principal_prop_set_report($path,&$options,&$files,$user) |
|
727 | + function acl_principal_prop_set_report($path, &$options, &$files, $user) |
|
729 | 728 | { |
730 | 729 | //error_log(__METHOD__."('$path', ".array2string($options).",, $user)"); |
731 | 730 | |
@@ -744,13 +743,13 @@ discard block |
||
744 | 743 | return $ret; |
745 | 744 | } |
746 | 745 | // now filter out not matching "files" |
747 | - foreach($files['files'] as $n => $resource) |
|
746 | + foreach ($files['files'] as $n => $resource) |
|
748 | 747 | { |
749 | - foreach($resource['props']['resourcetype']['val'] as $prop) |
|
748 | + foreach ($resource['props']['resourcetype']['val'] as $prop) |
|
750 | 749 | { |
751 | 750 | if ($prop['name'] == 'principal') continue 2; |
752 | 751 | } |
753 | - unset($files['files'][$n]); // not a principal --> do not return |
|
752 | + unset($files['files'][$n]); // not a principal --> do not return |
|
754 | 753 | } |
755 | 754 | // we should not return it |
756 | 755 | unset($options['props']['resourcetype']); |
@@ -766,7 +765,7 @@ discard block |
||
766 | 765 | * @param array $options |
767 | 766 | * @return array|string array with files or HTTP error code |
768 | 767 | */ |
769 | - protected function propfind_users($name,$rest,array $options) |
|
768 | + protected function propfind_users($name, $rest, array $options) |
|
770 | 769 | { |
771 | 770 | //error_log(__METHOD__."($name,$rest,".array2string($options).')'); |
772 | 771 | if (empty($name)) |
@@ -788,7 +787,7 @@ discard block |
||
788 | 787 | else |
789 | 788 | { |
790 | 789 | // add all users (account_selection == groupmembers is handled by accounts->search()) |
791 | - foreach($this->accounts->search(array('type' => 'accounts','order' => 'account_lid')) as $account) |
|
790 | + foreach ($this->accounts->search(array('type' => 'accounts', 'order' => 'account_lid')) as $account) |
|
792 | 791 | { |
793 | 792 | $files[] = $this->add_account($account); |
794 | 793 | } |
@@ -797,18 +796,18 @@ discard block |
||
797 | 796 | } |
798 | 797 | else |
799 | 798 | { |
800 | - if (!($id = $this->accounts->name2id($name,'account_lid','u')) || |
|
799 | + if (!($id = $this->accounts->name2id($name, 'account_lid', 'u')) || |
|
801 | 800 | !($account = $this->accounts->read($id)) || |
802 | 801 | !$this->accounts->visible($name)) |
803 | 802 | { |
804 | 803 | $this->caldav->log(__METHOD__."('$name', ...) account '$name' NOT found OR not visible to you (check account-selection preference)!"); |
805 | 804 | return '404 Not Found'; |
806 | 805 | } |
807 | - while (substr($rest,-1) == '/') |
|
806 | + while (substr($rest, -1) == '/') |
|
808 | 807 | { |
809 | - $rest = substr($rest,0,-1); |
|
808 | + $rest = substr($rest, 0, -1); |
|
810 | 809 | } |
811 | - switch((string)$rest) |
|
810 | + switch ((string)$rest) |
|
812 | 811 | { |
813 | 812 | case '': |
814 | 813 | $files[] = $this->add_account($account); |
@@ -838,7 +837,7 @@ discard block |
||
838 | 837 | * @param array $options |
839 | 838 | * @return array|string array with files or HTTP error code |
840 | 839 | */ |
841 | - protected function propfind_groups($name,$rest,array $options) |
|
840 | + protected function propfind_groups($name, $rest, array $options) |
|
842 | 841 | { |
843 | 842 | //echo "<p>".__METHOD__."($name,$rest,".array2string($options).")</p>\n"; |
844 | 843 | if (empty($name)) |
@@ -850,11 +849,11 @@ discard block |
||
850 | 849 | if ($options['depth']) |
851 | 850 | { |
852 | 851 | // only show own groups, if account-selection is groupmembers or none |
853 | - $type = in_array($GLOBALS['egw_info']['user']['preferences']['common']['account_selection'], array('groupmembers','none')) ? |
|
852 | + $type = in_array($GLOBALS['egw_info']['user']['preferences']['common']['account_selection'], array('groupmembers', 'none')) ? |
|
854 | 853 | 'owngroups' : 'groups'; |
855 | 854 | |
856 | 855 | // add all groups or only membergroups |
857 | - foreach($this->accounts->search(array('type' => $type,'order' => 'account_lid')) as $account) |
|
856 | + foreach ($this->accounts->search(array('type' => $type, 'order' => 'account_lid')) as $account) |
|
858 | 857 | { |
859 | 858 | $files[] = $this->add_group($account); |
860 | 859 | } |
@@ -862,19 +861,19 @@ discard block |
||
862 | 861 | } |
863 | 862 | else |
864 | 863 | { |
865 | - if (!($id = $this->accounts->name2id($name,'account_lid','g')) || |
|
864 | + if (!($id = $this->accounts->name2id($name, 'account_lid', 'g')) || |
|
866 | 865 | !($account = $this->accounts->read($id)) || |
867 | 866 | // do NOT allow other groups, if account-selection is groupmembers or none |
868 | - in_array($GLOBALS['egw_info']['user']['preferences']['common']['account_selection'], array('groupmembers','none')) && |
|
869 | - !in_array($account['account_id'], $this->accounts->memberships($GLOBALS['egw_info']['user']['account_id'],true))) |
|
867 | + in_array($GLOBALS['egw_info']['user']['preferences']['common']['account_selection'], array('groupmembers', 'none')) && |
|
868 | + !in_array($account['account_id'], $this->accounts->memberships($GLOBALS['egw_info']['user']['account_id'], true))) |
|
870 | 869 | { |
871 | 870 | return '404 Not Found'; |
872 | 871 | } |
873 | - while (substr($rest,-1) == '/') |
|
872 | + while (substr($rest, -1) == '/') |
|
874 | 873 | { |
875 | - $rest = substr($rest,0,-1); |
|
874 | + $rest = substr($rest, 0, -1); |
|
876 | 875 | } |
877 | - switch((string)$rest) |
|
876 | + switch ((string)$rest) |
|
878 | 877 | { |
879 | 878 | case '': |
880 | 879 | $files[] = $this->add_group($account); |
@@ -905,10 +904,10 @@ discard block |
||
905 | 904 | { |
906 | 905 | $addressbooks = array(); |
907 | 906 | $ab_home_set = $GLOBALS['egw_info']['user']['preferences']['groupdav']['addressbook-home-set']; |
908 | - if (empty($ab_home_set)) $ab_home_set = 'P'; // personal addressbook |
|
907 | + if (empty($ab_home_set)) $ab_home_set = 'P'; // personal addressbook |
|
909 | 908 | $addressbook_home_set = explode(',', $ab_home_set); |
910 | 909 | // replace symbolic id's with real nummeric id's |
911 | - foreach(array( |
|
910 | + foreach (array( |
|
912 | 911 | 'P' => $GLOBALS['egw_info']['user']['account_id'], |
913 | 912 | 'G' => $GLOBALS['egw_info']['user']['account_primary_group'], |
914 | 913 | 'U' => '0', |
@@ -919,13 +918,13 @@ discard block |
||
919 | 918 | $addressbook_home_set[$key] = $id; |
920 | 919 | } |
921 | 920 | } |
922 | - if (in_array('O',$addressbook_home_set)) // "all in one" from groupdav.php/addressbook/ |
|
921 | + if (in_array('O', $addressbook_home_set)) // "all in one" from groupdav.php/addressbook/ |
|
923 | 922 | { |
924 | 923 | $addressbooks[] = '/'; |
925 | 924 | } |
926 | - foreach(array_keys($GLOBALS['egw']->contacts->get_addressbooks(Api\Acl::READ)) as $id) |
|
925 | + foreach (array_keys($GLOBALS['egw']->contacts->get_addressbooks(Api\Acl::READ)) as $id) |
|
927 | 926 | { |
928 | - if ((in_array('A',$addressbook_home_set) || in_array((string)$id,$addressbook_home_set)) && |
|
927 | + if ((in_array('A', $addressbook_home_set) || in_array((string)$id, $addressbook_home_set)) && |
|
929 | 928 | is_numeric($id) && ($owner = $this->accounts->id2name($id))) |
930 | 929 | { |
931 | 930 | $addressbooks[] = '/'.$owner.'/'; |
@@ -949,45 +948,45 @@ discard block |
||
949 | 948 | $calendars[] = Api\CalDAV::mkprop('href', |
950 | 949 | $this->base_uri.'/'.$account['account_lid'].'/'); |
951 | 950 | |
952 | - $displayname = Api\Translation::convert($account['account_fullname'], Api\Translation::charset(),'utf-8'); |
|
951 | + $displayname = Api\Translation::convert($account['account_fullname'], Api\Translation::charset(), 'utf-8'); |
|
953 | 952 | |
954 | 953 | return $this->add_principal('users/'.$account['account_lid'], array( |
955 | 954 | 'getetag' => $this->get_etag($account), |
956 | 955 | 'displayname' => $displayname, |
957 | 956 | // CalDAV |
958 | - 'calendar-home-set' => Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-home-set',$calendars), |
|
957 | + 'calendar-home-set' => Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-home-set', $calendars), |
|
959 | 958 | // CalDAV scheduling |
960 | - 'schedule-outbox-URL' => Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'schedule-outbox-URL',array( |
|
961 | - Api\CalDAV::mkprop('href',$this->base_uri.'/'.$account['account_lid'].'/outbox/'))), |
|
962 | - 'schedule-inbox-URL' => Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'schedule-inbox-URL',array( |
|
963 | - Api\CalDAV::mkprop('href',$this->base_uri.'/'.$account['account_lid'].'/inbox/'))), |
|
964 | - 'calendar-user-address-set' => Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-user-address-set',array( |
|
965 | - Api\CalDAV::mkprop('href','mailto:'.$account['account_email']), |
|
966 | - Api\CalDAV::mkprop('href',$this->base_uri(true).'/principals/users/'.$account['account_lid'].'/'), |
|
967 | - Api\CalDAV::mkprop('href',$this->base_uri(false).'/principals/users/'.$account['account_lid'].'/'), |
|
968 | - Api\CalDAV::mkprop('href','urn:uuid:'.Api\CalDAV::generate_uid('accounts', $account['account_id'])), |
|
959 | + 'schedule-outbox-URL' => Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'schedule-outbox-URL', array( |
|
960 | + Api\CalDAV::mkprop('href', $this->base_uri.'/'.$account['account_lid'].'/outbox/'))), |
|
961 | + 'schedule-inbox-URL' => Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'schedule-inbox-URL', array( |
|
962 | + Api\CalDAV::mkprop('href', $this->base_uri.'/'.$account['account_lid'].'/inbox/'))), |
|
963 | + 'calendar-user-address-set' => Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-user-address-set', array( |
|
964 | + Api\CalDAV::mkprop('href', 'mailto:'.$account['account_email']), |
|
965 | + Api\CalDAV::mkprop('href', $this->base_uri(true).'/principals/users/'.$account['account_lid'].'/'), |
|
966 | + Api\CalDAV::mkprop('href', $this->base_uri(false).'/principals/users/'.$account['account_lid'].'/'), |
|
967 | + Api\CalDAV::mkprop('href', 'urn:uuid:'.Api\CalDAV::generate_uid('accounts', $account['account_id'])), |
|
969 | 968 | )), |
970 | - 'calendar-user-type' => Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-user-type','INDIVIDUAL'), |
|
969 | + 'calendar-user-type' => Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-user-type', 'INDIVIDUAL'), |
|
971 | 970 | // Calendarserver |
972 | - 'email-address-set' => Api\CalDAV::mkprop(Api\CalDAV::CALENDARSERVER,'email-address-set',array( |
|
973 | - Api\CalDAV::mkprop(Api\CalDAV::CALENDARSERVER,'email-address',$account['account_email']))), |
|
974 | - 'last-name' => Api\CalDAV::mkprop(Api\CalDAV::CALENDARSERVER,'last-name',$account['account_lastname']), |
|
975 | - 'first-name' => Api\CalDAV::mkprop(Api\CalDAV::CALENDARSERVER,'first-name',$account['account_firstname']), |
|
976 | - 'record-type' => Api\CalDAV::mkprop(Api\CalDAV::CALENDARSERVER,'record-type','users'), |
|
971 | + 'email-address-set' => Api\CalDAV::mkprop(Api\CalDAV::CALENDARSERVER, 'email-address-set', array( |
|
972 | + Api\CalDAV::mkprop(Api\CalDAV::CALENDARSERVER, 'email-address', $account['account_email']))), |
|
973 | + 'last-name' => Api\CalDAV::mkprop(Api\CalDAV::CALENDARSERVER, 'last-name', $account['account_lastname']), |
|
974 | + 'first-name' => Api\CalDAV::mkprop(Api\CalDAV::CALENDARSERVER, 'first-name', $account['account_firstname']), |
|
975 | + 'record-type' => Api\CalDAV::mkprop(Api\CalDAV::CALENDARSERVER, 'record-type', 'users'), |
|
977 | 976 | // WebDAV ACL and CalDAV proxy |
978 | 977 | 'group-membership' => $this->principal_set('group-membership', $this->accounts->memberships($account['account_id']), |
979 | - array('calendar', 'resources'), $account['account_id']), // add proxy-rights |
|
978 | + array('calendar', 'resources'), $account['account_id']), // add proxy-rights |
|
980 | 979 | 'alternate-URI-set' => array( |
981 | - Api\CalDAV::mkprop('href','mailto:'.$account['account_email'])), |
|
980 | + Api\CalDAV::mkprop('href', 'mailto:'.$account['account_email'])), |
|
982 | 981 | // CardDAV |
983 | - 'addressbook-home-set' => Api\CalDAV::mkprop(Api\CalDAV::CARDDAV,'addressbook-home-set',$addressbooks), |
|
984 | - 'principal-address' => Api\CalDAV::mkprop(Api\CalDAV::CARDDAV,'principal-address', |
|
982 | + 'addressbook-home-set' => Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'addressbook-home-set', $addressbooks), |
|
983 | + 'principal-address' => Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'principal-address', |
|
985 | 984 | $GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] === '1' ? '' : array( |
986 | - Api\CalDAV::mkprop('href',$this->base_uri.'/addressbook-accounts/'.$account['person_id'].'.vcf'))), |
|
985 | + Api\CalDAV::mkprop('href', $this->base_uri.'/addressbook-accounts/'.$account['person_id'].'.vcf'))), |
|
987 | 986 | // CardDAV directory |
988 | - 'directory-gateway' => Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'directory-gateway',array( |
|
987 | + 'directory-gateway' => Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'directory-gateway', array( |
|
989 | 988 | Api\CalDAV::mkprop('href', $this->base_uri.'/addressbook/'))), |
990 | - 'resource-id' => array(Api\CalDAV::mkprop('href','urn:uuid:'.Api\CalDAV::generate_uid('accounts', $account['account_id']))), |
|
989 | + 'resource-id' => array(Api\CalDAV::mkprop('href', 'urn:uuid:'.Api\CalDAV::generate_uid('accounts', $account['account_id']))), |
|
991 | 990 | )); |
992 | 991 | } |
993 | 992 | |
@@ -999,7 +998,7 @@ discard block |
||
999 | 998 | * @param string $cn =null common name to be stored in case of an "e" uid |
1000 | 999 | * @return int|string|boolean integer account_id, string calendar uid or false if not a supported uid |
1001 | 1000 | */ |
1002 | - static public function url2uid($url, $only_type=null, $cn=null) |
|
1001 | + static public function url2uid($url, $only_type = null, $cn = null) |
|
1003 | 1002 | { |
1004 | 1003 | if (!$only_type) $only_type = array('users', 'groups', 'resources', 'locations', 'mailto'); |
1005 | 1004 | |
@@ -1013,17 +1012,17 @@ discard block |
||
1013 | 1012 | } |
1014 | 1013 | if (empty($rest)) return false; |
1015 | 1014 | |
1016 | - switch(strtolower($schema)) |
|
1015 | + switch (strtolower($schema)) |
|
1017 | 1016 | { |
1018 | 1017 | case 'http': |
1019 | 1018 | case 'https': |
1020 | 1019 | list(,$rest) = explode('/groupdav.php/principals/', $url); |
1021 | 1020 | list($type, $name) = explode('/', $rest); |
1022 | - switch($type) |
|
1021 | + switch ($type) |
|
1023 | 1022 | { |
1024 | 1023 | case 'users': |
1025 | 1024 | case 'groups': |
1026 | - $uid = $GLOBALS['egw']->accounts->name2id($name, 'account_lid', $type[0]); // u=users, g=groups |
|
1025 | + $uid = $GLOBALS['egw']->accounts->name2id($name, 'account_lid', $type[0]); // u=users, g=groups |
|
1027 | 1026 | break; |
1028 | 1027 | case 'resources': |
1029 | 1028 | case 'locations': |
@@ -1040,9 +1039,9 @@ discard block |
||
1040 | 1039 | } |
1041 | 1040 | // search contacts for email |
1042 | 1041 | if ((list($data) = $GLOBALS['egw']->contacts->search(array('email' => $rest, 'email_home' => $rest), |
1043 | - array('id','egw_addressbook.account_id as account_id','n_fn'), |
|
1042 | + array('id', 'egw_addressbook.account_id as account_id', 'n_fn'), |
|
1044 | 1043 | 'egw_addressbook.account_id IS NOT NULL DESC, n_fn IS NOT NULL DESC', |
1045 | - '','',false,'OR'))) |
|
1044 | + '', '', false, 'OR'))) |
|
1046 | 1045 | { |
1047 | 1046 | // found an addressbook entry |
1048 | 1047 | $uid = $data['account_id'] ? (int)$data['account_id'] : 'c'.$data['id']; |
@@ -1060,7 +1059,7 @@ discard block |
||
1060 | 1059 | list($type, $id, $install_id) = explode('-', $uid); |
1061 | 1060 | if ($type == 'accounts' && empty($id)) // groups have a negative id, eg. "urn:uuid:accounts--1-..." |
1062 | 1061 | { |
1063 | - list($type, , $id_abs, $install_id) = explode('-', $uid); |
|
1062 | + list($type,, $id_abs, $install_id) = explode('-', $uid); |
|
1064 | 1063 | $id = -$id_abs; |
1065 | 1064 | } |
1066 | 1065 | // own urn |
@@ -1073,9 +1072,9 @@ discard block |
||
1073 | 1072 | } |
1074 | 1073 | else |
1075 | 1074 | { |
1076 | - static $calendar_bo=null; |
|
1075 | + static $calendar_bo = null; |
|
1077 | 1076 | if (is_null($calendar_bo)) $calendar_bo = new calendar_bo(); |
1078 | - foreach($calendar_bo->resources as $letter => $info) |
|
1077 | + foreach ($calendar_bo->resources as $letter => $info) |
|
1079 | 1078 | { |
1080 | 1079 | if ($info['app'] == $type || $info['app'] == 'resources' && $type == 'location') |
1081 | 1080 | { |
@@ -1088,7 +1087,7 @@ discard block |
||
1088 | 1087 | break; |
1089 | 1088 | |
1090 | 1089 | default: |
1091 | - if (isset($GLOBALS['groupdav']) && is_a($GLOBALS['groupdav'],'groupdav')) |
|
1090 | + if (isset($GLOBALS['groupdav']) && is_a($GLOBALS['groupdav'], 'groupdav')) |
|
1092 | 1091 | { |
1093 | 1092 | $GLOBALS['groupdav']->log(__METHOD__."('$url') unsupported principal URL '$url'!"); |
1094 | 1093 | } |
@@ -1106,7 +1105,7 @@ discard block |
||
1106 | 1105 | */ |
1107 | 1106 | protected function add_group(array $account) |
1108 | 1107 | { |
1109 | - $displayname = Api\Translation::convert(lang('Group').' '.$account['account_lid'], Api\Translation::charset(), 'utf-8'); |
|
1108 | + $displayname = Api\Translation::convert(lang('Group').' '.$account['account_lid'], Api\Translation::charset(), 'utf-8'); |
|
1110 | 1109 | |
1111 | 1110 | // only return current user, if account-selection == 'none' |
1112 | 1111 | if ($GLOBALS['egw_info']['user']['preferences']['common']['account_selection'] == 'none') |
@@ -1121,19 +1120,19 @@ discard block |
||
1121 | 1120 | return $this->add_principal('groups/'.$account['account_lid'], array( |
1122 | 1121 | 'getetag' => $this->get_etag($account), |
1123 | 1122 | 'displayname' => $displayname, |
1124 | - 'calendar-home-set' => Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-home-set',array( |
|
1125 | - Api\CalDAV::mkprop('href',$this->base_uri.'/'.$account['account_lid'].'/'))), |
|
1126 | - 'addressbook-home-set' => Api\CalDAV::mkprop(Api\CalDAV::CARDDAV,'addressbook-home-set',array( |
|
1127 | - Api\CalDAV::mkprop('href',$this->base_uri.'/'.$account['account_lid'].'/'))), |
|
1128 | - 'calendar-user-address-set' => Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-user-address-set',array( |
|
1129 | - Api\CalDAV::mkprop('href',$this->base_uri(true).'/principals/groups/'.$account['account_lid'].'/'), |
|
1130 | - Api\CalDAV::mkprop('href',$this->base_uri(false).'/principals/groups/'.$account['account_lid'].'/'), |
|
1131 | - Api\CalDAV::mkprop('href','urn:uuid:'.Api\CalDAV::generate_uid('accounts', $account['account_id'])), |
|
1123 | + 'calendar-home-set' => Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-home-set', array( |
|
1124 | + Api\CalDAV::mkprop('href', $this->base_uri.'/'.$account['account_lid'].'/'))), |
|
1125 | + 'addressbook-home-set' => Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'addressbook-home-set', array( |
|
1126 | + Api\CalDAV::mkprop('href', $this->base_uri.'/'.$account['account_lid'].'/'))), |
|
1127 | + 'calendar-user-address-set' => Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-user-address-set', array( |
|
1128 | + Api\CalDAV::mkprop('href', $this->base_uri(true).'/principals/groups/'.$account['account_lid'].'/'), |
|
1129 | + Api\CalDAV::mkprop('href', $this->base_uri(false).'/principals/groups/'.$account['account_lid'].'/'), |
|
1130 | + Api\CalDAV::mkprop('href', 'urn:uuid:'.Api\CalDAV::generate_uid('accounts', $account['account_id'])), |
|
1132 | 1131 | )), |
1133 | - 'record-type' => Api\CalDAV::mkprop(Api\CalDAV::CALENDARSERVER,'record-type','groups'), |
|
1134 | - 'calendar-user-type' => Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-user-type','GROUP'), |
|
1132 | + 'record-type' => Api\CalDAV::mkprop(Api\CalDAV::CALENDARSERVER, 'record-type', 'groups'), |
|
1133 | + 'calendar-user-type' => Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-user-type', 'GROUP'), |
|
1135 | 1134 | 'group-member-set' => $this->principal_set('group-member-set', $groupmembers), |
1136 | - 'resource-id' => array(Api\CalDAV::mkprop('href','urn:uuid:'.Api\CalDAV::generate_uid('accounts', $account['account_id']))), |
|
1135 | + 'resource-id' => array(Api\CalDAV::mkprop('href', 'urn:uuid:'.Api\CalDAV::generate_uid('accounts', $account['account_id']))), |
|
1137 | 1136 | )); |
1138 | 1137 | } |
1139 | 1138 | |
@@ -1144,7 +1143,7 @@ discard block |
||
1144 | 1143 | * @param boolean $is_location =null |
1145 | 1144 | * @return array with values for keys 'path' and 'props' |
1146 | 1145 | */ |
1147 | - protected function add_principal_resource(array $resource, $is_location=null) |
|
1146 | + protected function add_principal_resource(array $resource, $is_location = null) |
|
1148 | 1147 | { |
1149 | 1148 | $displayname = null; |
1150 | 1149 | $name = $this->resource2name($resource, $is_location, $displayname); |
@@ -1152,18 +1151,18 @@ discard block |
||
1152 | 1151 | return $this->add_principal($name, array( |
1153 | 1152 | 'getetag' => $this->get_resource_etag($resource), |
1154 | 1153 | 'displayname' => $displayname, |
1155 | - 'calendar-user-address-set' => Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-user-address-set',array( |
|
1156 | - Api\CalDAV::mkprop('href',$this->base_uri(true).'/principals/'.$name.'/'), |
|
1157 | - Api\CalDAV::mkprop('href',$this->base_uri(false).'/principals/'.$name.'/'), |
|
1158 | - Api\CalDAV::mkprop('href','urn:uuid:'.Api\CalDAV::generate_uid('resources', $resource['res_id'])), |
|
1154 | + 'calendar-user-address-set' => Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-user-address-set', array( |
|
1155 | + Api\CalDAV::mkprop('href', $this->base_uri(true).'/principals/'.$name.'/'), |
|
1156 | + Api\CalDAV::mkprop('href', $this->base_uri(false).'/principals/'.$name.'/'), |
|
1157 | + Api\CalDAV::mkprop('href', 'urn:uuid:'.Api\CalDAV::generate_uid('resources', $resource['res_id'])), |
|
1159 | 1158 | )), |
1160 | - 'record-type' => Api\CalDAV::mkprop(Api\CalDAV::CALENDARSERVER,'record-type',$is_location ? 'locations' : 'resources'), |
|
1161 | - 'calendar-user-type' => Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-user-type',$is_location ? 'ROOM' : 'RESOURCE'), |
|
1162 | - 'resource-id' => array(Api\CalDAV::mkprop('href','urn:uuid:'.Api\CalDAV::generate_uid('resources', $resource['res_id']))), |
|
1159 | + 'record-type' => Api\CalDAV::mkprop(Api\CalDAV::CALENDARSERVER, 'record-type', $is_location ? 'locations' : 'resources'), |
|
1160 | + 'calendar-user-type' => Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-user-type', $is_location ? 'ROOM' : 'RESOURCE'), |
|
1161 | + 'resource-id' => array(Api\CalDAV::mkprop('href', 'urn:uuid:'.Api\CalDAV::generate_uid('resources', $resource['res_id']))), |
|
1163 | 1162 | // Calendarserver also reports empty email-address-set, thought iCal still does not show resources (only locations) |
1164 | - 'email-address-set' => Api\CalDAV::mkprop(Api\CalDAV::CALENDARSERVER,'email-address-set',''), |
|
1165 | - 'calendar-home-set' => Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-home-set',array( |
|
1166 | - Api\CalDAV::mkprop('href',$this->base_uri.'/'.$name.'/'))), |
|
1163 | + 'email-address-set' => Api\CalDAV::mkprop(Api\CalDAV::CALENDARSERVER, 'email-address-set', ''), |
|
1164 | + 'calendar-home-set' => Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-home-set', array( |
|
1165 | + Api\CalDAV::mkprop('href', $this->base_uri.'/'.$name.'/'))), |
|
1167 | 1166 | )); |
1168 | 1167 | } |
1169 | 1168 | |
@@ -1175,7 +1174,7 @@ discard block |
||
1175 | 1174 | * @param string &$displayname=null on return displayname of resource |
1176 | 1175 | * @return string eg. "locations/123-some-room" or "resouces/345-some-device" |
1177 | 1176 | */ |
1178 | - public static function resource2name($resource, &$is_location=null, &$displayname=null) |
|
1177 | + public static function resource2name($resource, &$is_location = null, &$displayname = null) |
|
1179 | 1178 | { |
1180 | 1179 | if (!is_array($resource) && !($resource = self::read_resource($resource))) |
1181 | 1180 | { |
@@ -1183,10 +1182,10 @@ discard block |
||
1183 | 1182 | } |
1184 | 1183 | if (is_null($is_location)) $is_location = self::resource_is_location($resource); |
1185 | 1184 | |
1186 | - $displayname = Api\Translation::convert($resource['name'], Api\Translation::charset(), 'utf-8'); |
|
1185 | + $displayname = Api\Translation::convert($resource['name'], Api\Translation::charset(), 'utf-8'); |
|
1187 | 1186 | |
1188 | 1187 | return ($is_location ? 'locations/' : 'resources/').$resource['res_id'].'-'. |
1189 | - preg_replace('/[^a-z0-9]+/i','-', Api\Translation::to_ascii($resource['name'])); |
|
1188 | + preg_replace('/[^a-z0-9]+/i', '-', Api\Translation::to_ascii($resource['name'])); |
|
1190 | 1189 | } |
1191 | 1190 | |
1192 | 1191 | /** |
@@ -1197,7 +1196,7 @@ discard block |
||
1197 | 1196 | */ |
1198 | 1197 | public static function resource_is_location($resource) |
1199 | 1198 | { |
1200 | - static $location_cats=null; |
|
1199 | + static $location_cats = null; |
|
1201 | 1200 | if (is_null($location_cats)) |
1202 | 1201 | { |
1203 | 1202 | $config = Api\Config::read('resources'); |
@@ -1218,7 +1217,7 @@ discard block |
||
1218 | 1217 | */ |
1219 | 1218 | public static function read_resource($res_id) |
1220 | 1219 | { |
1221 | - static $cache=null; // some per-request caching |
|
1220 | + static $cache = null; // some per-request caching |
|
1222 | 1221 | |
1223 | 1222 | if (isset(self::$all_resources) && isset(self::$all_resources[$res_id])) |
1224 | 1223 | { |
@@ -1260,7 +1259,7 @@ discard block |
||
1260 | 1259 | * @param int $user =null account_if of user, or null for current user |
1261 | 1260 | * @return array of array with values for res_id, cat_id and name (no other values1) |
1262 | 1261 | */ |
1263 | - public static function get_resources($user=null) |
|
1262 | + public static function get_resources($user = null) |
|
1264 | 1263 | { |
1265 | 1264 | if (!isset(self::$all_resources)) |
1266 | 1265 | { |
@@ -1268,18 +1267,18 @@ discard block |
||
1268 | 1267 | |
1269 | 1268 | self::$all_resources = array(); |
1270 | 1269 | $query = array( |
1271 | - 'show_bookable' => true, // ignore non-bookable resources |
|
1270 | + 'show_bookable' => true, // ignore non-bookable resources |
|
1272 | 1271 | 'filter2' => -3, |
1273 | 1272 | 'start' => 0, |
1274 | - 'num_rows' => 10000, // return all aka first 10000 entries |
|
1273 | + 'num_rows' => 10000, // return all aka first 10000 entries |
|
1275 | 1274 | ); |
1276 | 1275 | $rows = $readonlys = null; |
1277 | 1276 | if (self::$resources->get_rows($query, $rows, $readonlys)) |
1278 | 1277 | { |
1279 | 1278 | //_debug_array($rows); |
1280 | - foreach($rows as $resource) |
|
1279 | + foreach ($rows as $resource) |
|
1281 | 1280 | { |
1282 | - self::$all_resources[$resource['res_id']] = array_intersect_key($resource, array('res_id'=>true,'cat_id'=>true,'name'=>true)); |
|
1281 | + self::$all_resources[$resource['res_id']] = array_intersect_key($resource, array('res_id'=>true, 'cat_id'=>true, 'name'=>true)); |
|
1283 | 1282 | } |
1284 | 1283 | } |
1285 | 1284 | } |
@@ -1295,7 +1294,7 @@ discard block |
||
1295 | 1294 | */ |
1296 | 1295 | protected function get_resource_rights() |
1297 | 1296 | { |
1298 | - static $grants=null; |
|
1297 | + static $grants = null; |
|
1299 | 1298 | |
1300 | 1299 | if (is_null($grants)) |
1301 | 1300 | { |
@@ -1328,19 +1327,19 @@ discard block |
||
1328 | 1327 | * @param string $principal_url =null include given principal url, relative to principal-collection-set, default $principal |
1329 | 1328 | * @return array with values for keys 'path' and 'props' |
1330 | 1329 | */ |
1331 | - protected function add_principal($principal, array $props = array(), $principal_url=null) |
|
1330 | + protected function add_principal($principal, array $props = array(), $principal_url = null) |
|
1332 | 1331 | { |
1333 | 1332 | $props['resourcetype'][] = Api\CalDAV::mkprop('principal', ''); |
1334 | 1333 | |
1335 | 1334 | // required props per WebDAV ACL |
1336 | - foreach(array('alternate-URI-set', 'group-membership') as $name) |
|
1335 | + foreach (array('alternate-URI-set', 'group-membership') as $name) |
|
1337 | 1336 | { |
1338 | - if (!isset($props[$name])) $props[$name] = Api\CalDAV::mkprop($name,''); |
|
1337 | + if (!isset($props[$name])) $props[$name] = Api\CalDAV::mkprop($name, ''); |
|
1339 | 1338 | } |
1340 | 1339 | if (!$principal_url) $principal_url = $principal; |
1341 | 1340 | |
1342 | 1341 | $props['principal-URL'] = array( |
1343 | - Api\CalDAV::mkprop('href',$this->base_uri.'/principals/'.$principal.'/')); |
|
1342 | + Api\CalDAV::mkprop('href', $this->base_uri.'/principals/'.$principal.'/')); |
|
1344 | 1343 | |
1345 | 1344 | return $this->add_collection('/principals/'.$principal.'/', $props); |
1346 | 1345 | } |
@@ -1356,20 +1355,20 @@ discard block |
||
1356 | 1355 | * @param array $resource =null resource to use (to not query it multiple times from the database) |
1357 | 1356 | * @return array with values for 'path' and 'props' |
1358 | 1357 | */ |
1359 | - protected function add_proxys($principal, $type, array $proxys=array(), array $resource=null) |
|
1358 | + protected function add_proxys($principal, $type, array $proxys = array(), array $resource = null) |
|
1360 | 1359 | { |
1361 | 1360 | list($app,,$what) = explode('-', $type); |
1362 | 1361 | |
1363 | - if (true) $proxys = array(); // ignore parameter! |
|
1364 | - list($account_type,$account) = explode('/', $principal); |
|
1362 | + if (true) $proxys = array(); // ignore parameter! |
|
1363 | + list($account_type, $account) = explode('/', $principal); |
|
1365 | 1364 | |
1366 | - switch($account_type) |
|
1365 | + switch ($account_type) |
|
1367 | 1366 | { |
1368 | 1367 | case 'users': |
1369 | 1368 | case 'groups': |
1370 | 1369 | $account = $location = $this->accounts->name2id($account, 'account_lid', $account_type[0]); |
1371 | 1370 | $right = $what == 'write' ? Api\Acl::EDIT : Api\Acl::READ; |
1372 | - $mask = $what == 'write' ? Api\Acl::EDIT : Api\Acl::EDIT|Api\Acl::READ; // do NOT report write+read in read |
|
1371 | + $mask = $what == 'write' ? Api\Acl::EDIT : Api\Acl::EDIT|Api\Acl::READ; // do NOT report write+read in read |
|
1373 | 1372 | break; |
1374 | 1373 | |
1375 | 1374 | case 'locations': |
@@ -1381,18 +1380,18 @@ discard block |
||
1381 | 1380 | } |
1382 | 1381 | $location = 'L'.$resource['cat_id']; |
1383 | 1382 | $right = $what == 'write' ? resources_acl_bo::DIRECT_BOOKING : resources_acl_bo::CAL_READ; |
1384 | - $mask = $what == 'write' ? resources_acl_bo::DIRECT_BOOKING : resources_acl_bo::DIRECT_BOOKING|resources_acl_bo::CAL_READ; // do NOT report write+read in read |
|
1383 | + $mask = $what == 'write' ? resources_acl_bo::DIRECT_BOOKING : resources_acl_bo::DIRECT_BOOKING|resources_acl_bo::CAL_READ; // do NOT report write+read in read |
|
1385 | 1384 | break; |
1386 | 1385 | } |
1387 | 1386 | static $principal2grants = array(); |
1388 | - $grants =& $principal2grants[$principal]; |
|
1387 | + $grants = & $principal2grants[$principal]; |
|
1389 | 1388 | if (!isset($grants)) |
1390 | 1389 | { |
1391 | - switch($app) |
|
1390 | + switch ($app) |
|
1392 | 1391 | { |
1393 | 1392 | case 'resources': |
1394 | 1393 | $res_grants = $this->get_resource_rights(); |
1395 | - $grants = (array)$res_grants[$location]; // returns array($location => $grants) |
|
1394 | + $grants = (array)$res_grants[$location]; // returns array($location => $grants) |
|
1396 | 1395 | break; |
1397 | 1396 | |
1398 | 1397 | case 'calendar': |
@@ -1402,9 +1401,9 @@ discard block |
||
1402 | 1401 | } |
1403 | 1402 | //echo "<p>type=$type --> app=$app, what=$what --> right=$right, mask=$mask, account=$account, location=$location --> grants=".array2string($grants)."</p>\n"; |
1404 | 1403 | } |
1405 | - foreach($grants as $account_id => $rights) |
|
1404 | + foreach ($grants as $account_id => $rights) |
|
1406 | 1405 | { |
1407 | - if ($account_id !== 'run' && $account_id != $account && ($rights & $mask) == $right && |
|
1406 | + if ($account_id !== 'run' && $account_id != $account && ($rights&$mask) == $right && |
|
1408 | 1407 | ($account_lid = $this->accounts->id2name($account_id))) |
1409 | 1408 | { |
1410 | 1409 | // ignore "broken" grants (eg. negative account_id for a user), as they lead to further errors (no members) |
@@ -1435,12 +1434,12 @@ discard block |
||
1435 | 1434 | * @param int $account who is the proxy |
1436 | 1435 | * @return array with href props |
1437 | 1436 | */ |
1438 | - protected function principal_set($prop, array $accounts=array(), $app_proxys=null, $account=null) |
|
1437 | + protected function principal_set($prop, array $accounts = array(), $app_proxys = null, $account = null) |
|
1439 | 1438 | { |
1440 | - unset($prop); // not used, but required by function signature |
|
1439 | + unset($prop); // not used, but required by function signature |
|
1441 | 1440 | |
1442 | 1441 | $set = array(); |
1443 | - foreach($accounts as $account_id => $account_lid) |
|
1442 | + foreach ($accounts as $account_id => $account_lid) |
|
1444 | 1443 | { |
1445 | 1444 | if ($this->accounts->visible($account_lid)) // only add visible accounts, gives error in iCal otherwise |
1446 | 1445 | { |
@@ -1449,11 +1448,11 @@ discard block |
||
1449 | 1448 | } |
1450 | 1449 | if ($app_proxys) |
1451 | 1450 | { |
1452 | - foreach((array)$app_proxys as $app) |
|
1451 | + foreach ((array)$app_proxys as $app) |
|
1453 | 1452 | { |
1454 | 1453 | if (!isset($GLOBALS['egw_info']['user']['apps'][$app])) continue; |
1455 | 1454 | |
1456 | - switch($app) |
|
1455 | + switch ($app) |
|
1457 | 1456 | { |
1458 | 1457 | case 'resources': |
1459 | 1458 | $proxy_groups = $this->get_resource_proxy_groups($account); |
@@ -1485,11 +1484,11 @@ discard block |
||
1485 | 1484 | // get location grants for $account (incl. his memberships) |
1486 | 1485 | $memberships = $GLOBALS['egw']->accounts->memberships($account, true); |
1487 | 1486 | $location_grants = array(); |
1488 | - foreach($all_location_grants as $location => $grants) |
|
1487 | + foreach ($all_location_grants as $location => $grants) |
|
1489 | 1488 | { |
1490 | - foreach($grants as $account_id => $rights) |
|
1489 | + foreach ($grants as $account_id => $rights) |
|
1491 | 1490 | { |
1492 | - if (($rights & (resources_acl_bo::CAL_READ|resources_acl_bo::DIRECT_BOOKING)) && // we only care for these rights |
|
1491 | + if (($rights&(resources_acl_bo::CAL_READ|resources_acl_bo::DIRECT_BOOKING)) && // we only care for these rights |
|
1493 | 1492 | ($account_id == $account || in_array($account_id, $memberships))) |
1494 | 1493 | { |
1495 | 1494 | if (!isset($location_grants[$location])) $location_grants[$location] = 0; |
@@ -1498,13 +1497,13 @@ discard block |
||
1498 | 1497 | } |
1499 | 1498 | } |
1500 | 1499 | // now add proxy-groups for all resources user has rights to |
1501 | - foreach($resources as $resource) |
|
1500 | + foreach ($resources as $resource) |
|
1502 | 1501 | { |
1503 | 1502 | $rights = $location_grants['L'.$resource['cat_id']]; |
1504 | 1503 | if (isset($rights)) |
1505 | 1504 | { |
1506 | 1505 | $set[] = Api\CalDAV::mkprop('href', $this->base_uri.'/principals/'.$this->resource2name($resource). |
1507 | - '/calendar-proxy-'.($rights & resources_acl_bo::DIRECT_BOOKING ? 'write' : 'read').'/'); |
|
1506 | + '/calendar-proxy-'.($rights&resources_acl_bo::DIRECT_BOOKING ? 'write' : 'read').'/'); |
|
1508 | 1507 | } |
1509 | 1508 | } |
1510 | 1509 | } |
@@ -1519,18 +1518,18 @@ discard block |
||
1519 | 1518 | * @param string $app ='calendar' applications for which proxys should be added |
1520 | 1519 | * @return array with href props |
1521 | 1520 | */ |
1522 | - protected function get_calendar_proxy_groups($account, $app='calendar') |
|
1521 | + protected function get_calendar_proxy_groups($account, $app = 'calendar') |
|
1523 | 1522 | { |
1524 | 1523 | $set = array(); |
1525 | - foreach($this->acl->get_grants($app, $app != 'addressbook', $account) as $account_id => $rights) |
|
1524 | + foreach ($this->acl->get_grants($app, $app != 'addressbook', $account) as $account_id => $rights) |
|
1526 | 1525 | { |
1527 | - if ($account_id != $account && ($rights & Api\Acl::READ) && |
|
1526 | + if ($account_id != $account && ($rights&Api\Acl::READ) && |
|
1528 | 1527 | ($account_lid = $this->accounts->id2name($account_id)) && |
1529 | 1528 | $this->accounts->visible($account_lid)) // only add visible accounts, gives error in iCal otherwise |
1530 | 1529 | { |
1531 | 1530 | $set[] = Api\CalDAV::mkprop('href', $this->base_uri.'/principals/'. |
1532 | 1531 | ($account_id < 0 ? 'groups/' : 'users/'). |
1533 | - $account_lid.'/'.$app.'-proxy-'.($rights & Api\Acl::EDIT ? 'write' : 'read').'/'); |
|
1532 | + $account_lid.'/'.$app.'-proxy-'.($rights&Api\Acl::EDIT ? 'write' : 'read').'/'); |
|
1534 | 1533 | } |
1535 | 1534 | } |
1536 | 1535 | return $set; |
@@ -1545,7 +1544,7 @@ discard block |
||
1545 | 1544 | * @param boolean $do_locations =false false: /principal/resources, true: /principals/locations |
1546 | 1545 | * @return array|string array with files or HTTP error code |
1547 | 1546 | */ |
1548 | - protected function propfind_resources($name,$rest,array $options,$do_locations=false) |
|
1547 | + protected function propfind_resources($name, $rest, array $options, $do_locations = false) |
|
1549 | 1548 | { |
1550 | 1549 | if (!isset($GLOBALS['egw_info']['user']['apps']['resources'])) |
1551 | 1550 | { |
@@ -1564,7 +1563,7 @@ discard block |
||
1564 | 1563 | if (($resources = $this->get_resources())) |
1565 | 1564 | { |
1566 | 1565 | //_debug_array($resources); |
1567 | - foreach($resources as $resource) |
|
1566 | + foreach ($resources as $resource) |
|
1568 | 1567 | { |
1569 | 1568 | if (($is_location = self::resource_is_location($resource)) == $do_locations) |
1570 | 1569 | { |
@@ -1581,11 +1580,11 @@ discard block |
||
1581 | 1580 | return '404 Not Found'; |
1582 | 1581 | } |
1583 | 1582 | $path = ($is_location ? 'locations/' : 'resources/').$name; |
1584 | - while (substr($rest,-1) == '/') |
|
1583 | + while (substr($rest, -1) == '/') |
|
1585 | 1584 | { |
1586 | - $rest = substr($rest,0,-1); |
|
1585 | + $rest = substr($rest, 0, -1); |
|
1587 | 1586 | } |
1588 | - switch((string)$rest) |
|
1587 | + switch ((string)$rest) |
|
1589 | 1588 | { |
1590 | 1589 | case '': |
1591 | 1590 | $files[] = $this->add_principal_resource($resource); |
@@ -1624,12 +1623,12 @@ discard block |
||
1624 | 1623 | if ($options['depth']) |
1625 | 1624 | { |
1626 | 1625 | if (is_numeric($options['depth'])) --$options['depth']; |
1627 | - $files = array_merge($files, $this->propfind_users('','',$options), |
|
1628 | - $this->propfind_groups('','',$options)); |
|
1626 | + $files = array_merge($files, $this->propfind_users('', '', $options), |
|
1627 | + $this->propfind_groups('', '', $options)); |
|
1629 | 1628 | if ($GLOBALS['egw_info']['user']['apps']['resources']) |
1630 | 1629 | { |
1631 | - $files = array_merge($files, $this->propfind_resources('','',$options,false), // resources |
|
1632 | - $this->propfind_resources('','',$options,true)); // locations |
|
1630 | + $files = array_merge($files, $this->propfind_resources('', '', $options, false), // resources |
|
1631 | + $this->propfind_resources('', '', $options, true)); // locations |
|
1633 | 1632 | } |
1634 | 1633 | //$files = array_merge($files,$this->propfind_uids('','',$options)); |
1635 | 1634 | } |
@@ -1644,9 +1643,9 @@ discard block |
||
1644 | 1643 | * @param int $user =null account_id |
1645 | 1644 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
1646 | 1645 | */ |
1647 | - function get(&$options,$id,$user=null) |
|
1646 | + function get(&$options, $id, $user = null) |
|
1648 | 1647 | { |
1649 | - unset($options, $id, $user); // not used, but required by function signature |
|
1648 | + unset($options, $id, $user); // not used, but required by function signature |
|
1650 | 1649 | |
1651 | 1650 | return false; |
1652 | 1651 | } |
@@ -1659,9 +1658,9 @@ discard block |
||
1659 | 1658 | * @param int $user =null account_id of owner, default null |
1660 | 1659 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
1661 | 1660 | */ |
1662 | - function put(&$options,$id,$user=null) |
|
1661 | + function put(&$options, $id, $user = null) |
|
1663 | 1662 | { |
1664 | - unset($options, $id, $user); // not used, but required by function signature |
|
1663 | + unset($options, $id, $user); // not used, but required by function signature |
|
1665 | 1664 | |
1666 | 1665 | return false; |
1667 | 1666 | } |
@@ -1673,9 +1672,9 @@ discard block |
||
1673 | 1672 | * @param int $id |
1674 | 1673 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
1675 | 1674 | */ |
1676 | - function delete(&$options,$id) |
|
1675 | + function delete(&$options, $id) |
|
1677 | 1676 | { |
1678 | - unset($options, $id); // not used, but required by function signature |
|
1677 | + unset($options, $id); // not used, but required by function signature |
|
1679 | 1678 | |
1680 | 1679 | return false; |
1681 | 1680 | } |
@@ -1688,7 +1687,7 @@ discard block |
||
1688 | 1687 | */ |
1689 | 1688 | function read($id) |
1690 | 1689 | { |
1691 | - unset($id); // not used, but required by function signature |
|
1690 | + unset($id); // not used, but required by function signature |
|
1692 | 1691 | |
1693 | 1692 | return false; |
1694 | 1693 | } |
@@ -1700,13 +1699,13 @@ discard block |
||
1700 | 1699 | * @param array|int $entry entry-array or id |
1701 | 1700 | * @return boolean null if entry does not exist, false if no access, true if access permitted |
1702 | 1701 | */ |
1703 | - function check_access($acl,$entry) |
|
1702 | + function check_access($acl, $entry) |
|
1704 | 1703 | { |
1705 | 1704 | if ($acl != Api\Acl::READ) |
1706 | 1705 | { |
1707 | 1706 | return false; |
1708 | 1707 | } |
1709 | - if (!is_array($entry) && !$this->accounts->name2id($entry,'account_lid','u')) |
|
1708 | + if (!is_array($entry) && !$this->accounts->name2id($entry, 'account_lid', 'u')) |
|
1710 | 1709 | { |
1711 | 1710 | return null; |
1712 | 1711 | } |
@@ -1743,9 +1742,9 @@ discard block |
||
1743 | 1742 | * @param int $user =null owner of the collection, default current user |
1744 | 1743 | * @return array with privileges |
1745 | 1744 | */ |
1746 | - public function current_user_privileges($path, $user=null) |
|
1745 | + public function current_user_privileges($path, $user = null) |
|
1747 | 1746 | { |
1748 | - unset($path, $user); // not used, but required by function signature |
|
1747 | + unset($path, $user); // not used, but required by function signature |
|
1749 | 1748 | |
1750 | 1749 | return array('read', 'read-current-user-privilege-set'); |
1751 | 1750 | } |
@@ -48,7 +48,10 @@ discard block |
||
48 | 48 | { |
49 | 49 | parent::__construct($app, $caldav); |
50 | 50 | |
51 | - if (!isset(self::$resources)) self::$resources = new resources_bo(); |
|
51 | + if (!isset(self::$resources)) |
|
52 | + { |
|
53 | + self::$resources = new resources_bo(); |
|
54 | + } |
|
52 | 55 | } |
53 | 56 | |
54 | 57 | /** |
@@ -92,7 +95,10 @@ discard block |
||
92 | 95 | { |
93 | 96 | unset($path); // not used, but required by function signature |
94 | 97 | |
95 | - if (is_null($reports)) $reports = $this->supported_reports; |
|
98 | + if (is_null($reports)) |
|
99 | + { |
|
100 | + $reports = $this->supported_reports; |
|
101 | + } |
|
96 | 102 | |
97 | 103 | $supported = array(); |
98 | 104 | foreach($reports as $name => $data) |
@@ -263,7 +269,10 @@ discard block |
||
263 | 269 | $requested_props = $options['other']; |
264 | 270 | while(($requested_prop = array_shift($requested_props))) |
265 | 271 | { |
266 | - if ($requested_prop['name'] != 'property' || $requested_prop['depth'] != 1) continue; |
|
272 | + if ($requested_prop['name'] != 'property' || $requested_prop['depth'] != 1) |
|
273 | + { |
|
274 | + continue; |
|
275 | + } |
|
267 | 276 | |
268 | 277 | $prop_ns = $requested_prop['attrs']['namespace']; |
269 | 278 | $prop_name = $requested_prop['attrs']['name']; |
@@ -302,7 +311,10 @@ discard block |
||
302 | 311 | // find prop to expand |
303 | 312 | foreach($prop_files['files'][0]['props'] as $expand_prop) |
304 | 313 | { |
305 | - if ($expand_prop['name'] === $prop_name) break; |
|
314 | + if ($expand_prop['name'] === $prop_name) |
|
315 | + { |
|
316 | + break; |
|
317 | + } |
|
306 | 318 | } |
307 | 319 | if ($expand_prop['name'] !== $prop_name || !is_array($expand_prop['val']) || |
308 | 320 | $expand_prop['val'] && $expand_prop['val'][0]['name'] !== 'href') |
@@ -318,10 +330,13 @@ discard block |
||
318 | 330 | { |
319 | 331 | if ($prop['name'] == 'property' && $prop['depth'] == 2) |
320 | 332 | { |
321 | - if (!is_array($options2['props'])) // is "all" initially |
|
333 | + if (!is_array($options2['props'])) |
|
334 | + { |
|
335 | + // is "all" initially |
|
322 | 336 | { |
323 | 337 | $options2['props'] = array(); |
324 | 338 | } |
339 | + } |
|
325 | 340 | $options2['props'][] = array( |
326 | 341 | 'name' => $prop['attrs']['name'], |
327 | 342 | 'xmlns' => isset($prop['attrs']['namespace']) ? $prop['attrs']['namespace'] : $prop['xmlns'], |
@@ -329,7 +344,10 @@ discard block |
||
329 | 344 | } |
330 | 345 | } |
331 | 346 | // put back evtl. read top-level property |
332 | - if ($prop && $prop['depth'] == 1) array_unshift($requested_props, $prop); |
|
347 | + if ($prop && $prop['depth'] == 1) |
|
348 | + { |
|
349 | + array_unshift($requested_props, $prop); |
|
350 | + } |
|
333 | 351 | $this->caldav->options = $options2; // also modify global variable |
334 | 352 | |
335 | 353 | // run regular profind to get requested 2.-level properties for each href |
@@ -525,9 +543,12 @@ discard block |
||
525 | 543 | // now filter out not matching "files" |
526 | 544 | foreach($files['files'] as $n => $resource) |
527 | 545 | { |
528 | - if (count(explode('/', $resource['path'])) < 5) // hack to only return principals, not the collections itself |
|
546 | + if (count(explode('/', $resource['path'])) < 5) |
|
547 | + { |
|
548 | + // hack to only return principals, not the collections itself |
|
529 | 549 | { |
530 | 550 | unset($files['files'][$n]); |
551 | + } |
|
531 | 552 | continue; |
532 | 553 | } |
533 | 554 | // match with $search_props |
@@ -537,16 +558,26 @@ discard block |
||
537 | 558 | // search resource for $search_prop |
538 | 559 | foreach($resource['props'] as $prop) |
539 | 560 | { |
540 | - if ($prop['name'] === $search_prop['name']) break; |
|
561 | + if ($prop['name'] === $search_prop['name']) |
|
562 | + { |
|
563 | + break; |
|
564 | + } |
|
541 | 565 | } |
542 | - if ($prop['name'] === $search_prop['name']) // search_prop NOT found |
|
566 | + if ($prop['name'] === $search_prop['name']) |
|
567 | + { |
|
568 | + // search_prop NOT found |
|
543 | 569 | { |
544 | 570 | foreach((array)$prop['val'] as $value) |
545 | 571 | { |
546 | - if (is_array($value)) $value = $value['val']; // eg. href prop |
|
547 | - if (self::match($value, $search_prop['match'], $search_prop['match-type']) !== false) // prop does match |
|
572 | + if (is_array($value)) $value = $value['val']; |
|
573 | + } |
|
574 | + // eg. href prop |
|
575 | + if (self::match($value, $search_prop['match'], $search_prop['match-type']) !== false) |
|
576 | + { |
|
577 | + // prop does match |
|
548 | 578 | { |
549 | 579 | ++$matches; |
580 | + } |
|
550 | 581 | //error_log("$matches: $resource[path]: $search_prop[name]=".array2string($prop['name'] !== $search_prop['name'] ? null : $prop['val'])." does match '$search_prop[match]'"); |
551 | 582 | break; |
552 | 583 | } |
@@ -748,7 +779,10 @@ discard block |
||
748 | 779 | { |
749 | 780 | foreach($resource['props']['resourcetype']['val'] as $prop) |
750 | 781 | { |
751 | - if ($prop['name'] == 'principal') continue 2; |
|
782 | + if ($prop['name'] == 'principal') |
|
783 | + { |
|
784 | + continue 2; |
|
785 | + } |
|
752 | 786 | } |
753 | 787 | unset($files['files'][$n]); // not a principal --> do not return |
754 | 788 | } |
@@ -905,7 +939,11 @@ discard block |
||
905 | 939 | { |
906 | 940 | $addressbooks = array(); |
907 | 941 | $ab_home_set = $GLOBALS['egw_info']['user']['preferences']['groupdav']['addressbook-home-set']; |
908 | - if (empty($ab_home_set)) $ab_home_set = 'P'; // personal addressbook |
|
942 | + if (empty($ab_home_set)) |
|
943 | + { |
|
944 | + $ab_home_set = 'P'; |
|
945 | + } |
|
946 | + // personal addressbook |
|
909 | 947 | $addressbook_home_set = explode(',', $ab_home_set); |
910 | 948 | // replace symbolic id's with real nummeric id's |
911 | 949 | foreach(array( |
@@ -919,10 +957,13 @@ discard block |
||
919 | 957 | $addressbook_home_set[$key] = $id; |
920 | 958 | } |
921 | 959 | } |
922 | - if (in_array('O',$addressbook_home_set)) // "all in one" from groupdav.php/addressbook/ |
|
960 | + if (in_array('O',$addressbook_home_set)) |
|
961 | + { |
|
962 | + // "all in one" from groupdav.php/addressbook/ |
|
923 | 963 | { |
924 | 964 | $addressbooks[] = '/'; |
925 | 965 | } |
966 | + } |
|
926 | 967 | foreach(array_keys($GLOBALS['egw']->contacts->get_addressbooks(Api\Acl::READ)) as $id) |
927 | 968 | { |
928 | 969 | if ((in_array('A',$addressbook_home_set) || in_array((string)$id,$addressbook_home_set)) && |
@@ -1001,7 +1042,10 @@ discard block |
||
1001 | 1042 | */ |
1002 | 1043 | static public function url2uid($url, $only_type=null, $cn=null) |
1003 | 1044 | { |
1004 | - if (!$only_type) $only_type = array('users', 'groups', 'resources', 'locations', 'mailto'); |
|
1045 | + if (!$only_type) |
|
1046 | + { |
|
1047 | + $only_type = array('users', 'groups', 'resources', 'locations', 'mailto'); |
|
1048 | + } |
|
1005 | 1049 | |
1006 | 1050 | if ($url[0] == '/') |
1007 | 1051 | { |
@@ -1011,7 +1055,10 @@ discard block |
||
1011 | 1055 | { |
1012 | 1056 | list($schema, $rest) = explode(':', $url, 2); |
1013 | 1057 | } |
1014 | - if (empty($rest)) return false; |
|
1058 | + if (empty($rest)) |
|
1059 | + { |
|
1060 | + return false; |
|
1061 | + } |
|
1015 | 1062 | |
1016 | 1063 | switch(strtolower($schema)) |
1017 | 1064 | { |
@@ -1058,9 +1105,12 @@ discard block |
||
1058 | 1105 | case 'urn': |
1059 | 1106 | list($urn_type, $uid) = explode(':', $rest, 2); |
1060 | 1107 | list($type, $id, $install_id) = explode('-', $uid); |
1061 | - if ($type == 'accounts' && empty($id)) // groups have a negative id, eg. "urn:uuid:accounts--1-..." |
|
1108 | + if ($type == 'accounts' && empty($id)) |
|
1109 | + { |
|
1110 | + // groups have a negative id, eg. "urn:uuid:accounts--1-..." |
|
1062 | 1111 | { |
1063 | 1112 | list($type, , $id_abs, $install_id) = explode('-', $uid); |
1113 | + } |
|
1064 | 1114 | $id = -$id_abs; |
1065 | 1115 | } |
1066 | 1116 | // own urn |
@@ -1074,7 +1124,10 @@ discard block |
||
1074 | 1124 | else |
1075 | 1125 | { |
1076 | 1126 | static $calendar_bo=null; |
1077 | - if (is_null($calendar_bo)) $calendar_bo = new calendar_bo(); |
|
1127 | + if (is_null($calendar_bo)) |
|
1128 | + { |
|
1129 | + $calendar_bo = new calendar_bo(); |
|
1130 | + } |
|
1078 | 1131 | foreach($calendar_bo->resources as $letter => $info) |
1079 | 1132 | { |
1080 | 1133 | if ($info['app'] == $type || $info['app'] == 'resources' && $type == 'location') |
@@ -1181,7 +1234,10 @@ discard block |
||
1181 | 1234 | { |
1182 | 1235 | return null; |
1183 | 1236 | } |
1184 | - if (is_null($is_location)) $is_location = self::resource_is_location($resource); |
|
1237 | + if (is_null($is_location)) |
|
1238 | + { |
|
1239 | + $is_location = self::resource_is_location($resource); |
|
1240 | + } |
|
1185 | 1241 | |
1186 | 1242 | $displayname = Api\Translation::convert($resource['name'], Api\Translation::charset(), 'utf-8'); |
1187 | 1243 | |
@@ -1227,7 +1283,10 @@ discard block |
||
1227 | 1283 | |
1228 | 1284 | if (!isset($cache[$res_id])) |
1229 | 1285 | { |
1230 | - if (!isset(self::$resources)) self::$resources = new resources_bo(); |
|
1286 | + if (!isset(self::$resources)) |
|
1287 | + { |
|
1288 | + self::$resources = new resources_bo(); |
|
1289 | + } |
|
1231 | 1290 | |
1232 | 1291 | if (!($cache[$res_id] = self::$resources->read($res_id))) |
1233 | 1292 | { |
@@ -1264,7 +1323,10 @@ discard block |
||
1264 | 1323 | { |
1265 | 1324 | if (!isset(self::$all_resources)) |
1266 | 1325 | { |
1267 | - if (!isset(self::$resources)) self::$resources = new resources_bo($user); |
|
1326 | + if (!isset(self::$resources)) |
|
1327 | + { |
|
1328 | + self::$resources = new resources_bo($user); |
|
1329 | + } |
|
1268 | 1330 | |
1269 | 1331 | self::$all_resources = array(); |
1270 | 1332 | $query = array( |
@@ -1335,9 +1397,15 @@ discard block |
||
1335 | 1397 | // required props per WebDAV ACL |
1336 | 1398 | foreach(array('alternate-URI-set', 'group-membership') as $name) |
1337 | 1399 | { |
1338 | - if (!isset($props[$name])) $props[$name] = Api\CalDAV::mkprop($name,''); |
|
1400 | + if (!isset($props[$name])) |
|
1401 | + { |
|
1402 | + $props[$name] = Api\CalDAV::mkprop($name,''); |
|
1403 | + } |
|
1404 | + } |
|
1405 | + if (!$principal_url) |
|
1406 | + { |
|
1407 | + $principal_url = $principal; |
|
1339 | 1408 | } |
1340 | - if (!$principal_url) $principal_url = $principal; |
|
1341 | 1409 | |
1342 | 1410 | $props['principal-URL'] = array( |
1343 | 1411 | Api\CalDAV::mkprop('href',$this->base_uri.'/principals/'.$principal.'/')); |
@@ -1360,7 +1428,11 @@ discard block |
||
1360 | 1428 | { |
1361 | 1429 | list($app,,$what) = explode('-', $type); |
1362 | 1430 | |
1363 | - if (true) $proxys = array(); // ignore parameter! |
|
1431 | + if (true) |
|
1432 | + { |
|
1433 | + $proxys = array(); |
|
1434 | + } |
|
1435 | + // ignore parameter! |
|
1364 | 1436 | list($account_type,$account) = explode('/', $principal); |
1365 | 1437 | |
1366 | 1438 | switch($account_type) |
@@ -1442,16 +1514,22 @@ discard block |
||
1442 | 1514 | $set = array(); |
1443 | 1515 | foreach($accounts as $account_id => $account_lid) |
1444 | 1516 | { |
1445 | - if ($this->accounts->visible($account_lid)) // only add visible accounts, gives error in iCal otherwise |
|
1517 | + if ($this->accounts->visible($account_lid)) |
|
1518 | + { |
|
1519 | + // only add visible accounts, gives error in iCal otherwise |
|
1446 | 1520 | { |
1447 | 1521 | $set[] = Api\CalDAV::mkprop('href', $this->base_uri.'/principals/'.($account_id < 0 ? 'groups/' : 'users/').$account_lid.'/'); |
1448 | 1522 | } |
1523 | + } |
|
1449 | 1524 | } |
1450 | 1525 | if ($app_proxys) |
1451 | 1526 | { |
1452 | 1527 | foreach((array)$app_proxys as $app) |
1453 | 1528 | { |
1454 | - if (!isset($GLOBALS['egw_info']['user']['apps'][$app])) continue; |
|
1529 | + if (!isset($GLOBALS['egw_info']['user']['apps'][$app])) |
|
1530 | + { |
|
1531 | + continue; |
|
1532 | + } |
|
1455 | 1533 | |
1456 | 1534 | switch($app) |
1457 | 1535 | { |
@@ -1492,7 +1570,10 @@ discard block |
||
1492 | 1570 | if (($rights & (resources_acl_bo::CAL_READ|resources_acl_bo::DIRECT_BOOKING)) && // we only care for these rights |
1493 | 1571 | ($account_id == $account || in_array($account_id, $memberships))) |
1494 | 1572 | { |
1495 | - if (!isset($location_grants[$location])) $location_grants[$location] = 0; |
|
1573 | + if (!isset($location_grants[$location])) |
|
1574 | + { |
|
1575 | + $location_grants[$location] = 0; |
|
1576 | + } |
|
1496 | 1577 | $location_grants[$location] |= $rights; |
1497 | 1578 | } |
1498 | 1579 | } |
@@ -1526,12 +1607,15 @@ discard block |
||
1526 | 1607 | { |
1527 | 1608 | if ($account_id != $account && ($rights & Api\Acl::READ) && |
1528 | 1609 | ($account_lid = $this->accounts->id2name($account_id)) && |
1529 | - $this->accounts->visible($account_lid)) // only add visible accounts, gives error in iCal otherwise |
|
1610 | + $this->accounts->visible($account_lid)) |
|
1611 | + { |
|
1612 | + // only add visible accounts, gives error in iCal otherwise |
|
1530 | 1613 | { |
1531 | 1614 | $set[] = Api\CalDAV::mkprop('href', $this->base_uri.'/principals/'. |
1532 | 1615 | ($account_id < 0 ? 'groups/' : 'users/'). |
1533 | 1616 | $account_lid.'/'.$app.'-proxy-'.($rights & Api\Acl::EDIT ? 'write' : 'read').'/'); |
1534 | 1617 | } |
1618 | + } |
|
1535 | 1619 | } |
1536 | 1620 | return $set; |
1537 | 1621 | } |
@@ -1623,7 +1707,10 @@ discard block |
||
1623 | 1707 | |
1624 | 1708 | if ($options['depth']) |
1625 | 1709 | { |
1626 | - if (is_numeric($options['depth'])) --$options['depth']; |
|
1710 | + if (is_numeric($options['depth'])) |
|
1711 | + { |
|
1712 | + --$options['depth']; |
|
1713 | + } |
|
1627 | 1714 | $files = array_merge($files, $this->propfind_users('','',$options), |
1628 | 1715 | $this->propfind_groups('','',$options)); |
1629 | 1716 | if ($GLOBALS['egw_info']['user']['apps']['resources']) |
@@ -94,6 +94,7 @@ |
||
94 | 94 | * @param Handler $handler |
95 | 95 | * @param array $filter filter for propfind call |
96 | 96 | * @param array $files =array() extra files/responses to return too |
97 | + * @param string $path |
|
97 | 98 | */ |
98 | 99 | public function __construct(Handler $handler, $path, array $filter,array &$files=array()) |
99 | 100 | { |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @var int |
73 | 73 | */ |
74 | - protected $start=0; |
|
74 | + protected $start = 0; |
|
75 | 75 | |
76 | 76 | /** |
77 | 77 | * Number of entries queried from callback in one call |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * @param array $filter filter for propfind call |
96 | 96 | * @param array $files =array() extra files/responses to return too |
97 | 97 | */ |
98 | - public function __construct(Handler $handler, $path, array $filter,array &$files=array()) |
|
98 | + public function __construct(Handler $handler, $path, array $filter, array &$files = array()) |
|
99 | 99 | { |
100 | 100 | if ($this->debug) error_log(__METHOD__."('$path', ".array2string($filter).",)"); |
101 | 101 | $this->path = $path; |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | $current = current($this->files); |
127 | 127 | |
128 | 128 | if ($this->debug) error_log(__METHOD__."() returning ".array2string($current['path'])); |
129 | - return $current['path']; // we return path as key |
|
129 | + return $current['path']; // we return path as key |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -146,11 +146,11 @@ discard block |
||
146 | 146 | return false; |
147 | 147 | } |
148 | 148 | // try query further files via propfind callback of handler and store result in $this->files |
149 | - $this->files = $this->handler->propfind_callback($this->path,$this->filter,array($this->start,self::CHUNK_SIZE)); |
|
149 | + $this->files = $this->handler->propfind_callback($this->path, $this->filter, array($this->start, self::CHUNK_SIZE)); |
|
150 | 150 | if (!is_array($this->files) || !($entries = count($this->files))) |
151 | 151 | { |
152 | 152 | if ($this->debug) error_log(__METHOD__."() returning FALSE (no more entries)"); |
153 | - return false; // no further entries |
|
153 | + return false; // no further entries |
|
154 | 154 | } |
155 | 155 | $this->start += self::CHUNK_SIZE; |
156 | 156 | reset($this->files); |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | |
170 | 170 | $this->start = 0; |
171 | 171 | $this->files = $this->common_files; |
172 | - if (!$this->files) $this->next(); // otherwise valid will return false and nothing get returned |
|
172 | + if (!$this->files) $this->next(); // otherwise valid will return false and nothing get returned |
|
173 | 173 | reset($this->files); |
174 | 174 | } |
175 | 175 | |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | * |
179 | 179 | * @return boolean |
180 | 180 | */ |
181 | - public function valid () |
|
181 | + public function valid() |
|
182 | 182 | { |
183 | 183 | if ($this->debug) error_log(__METHOD__."() returning ".array2string(current($this->files) !== false)); |
184 | 184 | return current($this->files) !== false; |
@@ -97,7 +97,10 @@ discard block |
||
97 | 97 | */ |
98 | 98 | public function __construct(Handler $handler, $path, array $filter,array &$files=array()) |
99 | 99 | { |
100 | - if ($this->debug) error_log(__METHOD__."('$path', ".array2string($filter).",)"); |
|
100 | + if ($this->debug) |
|
101 | + { |
|
102 | + error_log(__METHOD__."('$path', ".array2string($filter).",)"); |
|
103 | + } |
|
101 | 104 | $this->path = $path; |
102 | 105 | $this->handler = $handler; |
103 | 106 | $this->filter = $filter; |
@@ -112,7 +115,10 @@ discard block |
||
112 | 115 | */ |
113 | 116 | public function current() |
114 | 117 | { |
115 | - if ($this->debug) error_log(__METHOD__."() returning ".array2string(current($this->files))); |
|
118 | + if ($this->debug) |
|
119 | + { |
|
120 | + error_log(__METHOD__."() returning ".array2string(current($this->files))); |
|
121 | + } |
|
116 | 122 | return current($this->files); |
117 | 123 | } |
118 | 124 | |
@@ -125,7 +131,10 @@ discard block |
||
125 | 131 | { |
126 | 132 | $current = current($this->files); |
127 | 133 | |
128 | - if ($this->debug) error_log(__METHOD__."() returning ".array2string($current['path'])); |
|
134 | + if ($this->debug) |
|
135 | + { |
|
136 | + error_log(__METHOD__."() returning ".array2string($current['path'])); |
|
137 | + } |
|
129 | 138 | return $current['path']; // we return path as key |
130 | 139 | } |
131 | 140 | |
@@ -136,26 +145,38 @@ discard block |
||
136 | 145 | { |
137 | 146 | if (next($this->files) !== false) |
138 | 147 | { |
139 | - if ($this->debug) error_log(__METHOD__."() returning TRUE"); |
|
148 | + if ($this->debug) |
|
149 | + { |
|
150 | + error_log(__METHOD__."() returning TRUE"); |
|
151 | + } |
|
140 | 152 | return true; |
141 | 153 | } |
142 | 154 | // check if previous query gave less then CHUNK_SIZE entries --> we're done |
143 | 155 | if ($this->start && count($this->files) < self::CHUNK_SIZE) |
144 | 156 | { |
145 | - if ($this->debug) error_log(__METHOD__."() returning FALSE (no more entries)"); |
|
157 | + if ($this->debug) |
|
158 | + { |
|
159 | + error_log(__METHOD__."() returning FALSE (no more entries)"); |
|
160 | + } |
|
146 | 161 | return false; |
147 | 162 | } |
148 | 163 | // try query further files via propfind callback of handler and store result in $this->files |
149 | 164 | $this->files = $this->handler->propfind_callback($this->path,$this->filter,array($this->start,self::CHUNK_SIZE)); |
150 | 165 | if (!is_array($this->files) || !($entries = count($this->files))) |
151 | 166 | { |
152 | - if ($this->debug) error_log(__METHOD__."() returning FALSE (no more entries)"); |
|
167 | + if ($this->debug) |
|
168 | + { |
|
169 | + error_log(__METHOD__."() returning FALSE (no more entries)"); |
|
170 | + } |
|
153 | 171 | return false; // no further entries |
154 | 172 | } |
155 | 173 | $this->start += self::CHUNK_SIZE; |
156 | 174 | reset($this->files); |
157 | 175 | |
158 | - if ($this->debug) error_log(__METHOD__."() this->start=$this->start, entries=$entries, count(this->files)=".count($this->files)." returning ".array2string(current($this->files) !== false)); |
|
176 | + if ($this->debug) |
|
177 | + { |
|
178 | + error_log(__METHOD__."() this->start=$this->start, entries=$entries, count(this->files)=".count($this->files)." returning ".array2string(current($this->files) !== false)); |
|
179 | + } |
|
159 | 180 | |
160 | 181 | return current($this->files) !== false; |
161 | 182 | } |
@@ -165,11 +186,18 @@ discard block |
||
165 | 186 | */ |
166 | 187 | public function rewind() |
167 | 188 | { |
168 | - if ($this->debug) error_log(__METHOD__."()"); |
|
189 | + if ($this->debug) |
|
190 | + { |
|
191 | + error_log(__METHOD__."()"); |
|
192 | + } |
|
169 | 193 | |
170 | 194 | $this->start = 0; |
171 | 195 | $this->files = $this->common_files; |
172 | - if (!$this->files) $this->next(); // otherwise valid will return false and nothing get returned |
|
196 | + if (!$this->files) |
|
197 | + { |
|
198 | + $this->next(); |
|
199 | + } |
|
200 | + // otherwise valid will return false and nothing get returned |
|
173 | 201 | reset($this->files); |
174 | 202 | } |
175 | 203 | |
@@ -180,7 +208,10 @@ discard block |
||
180 | 208 | */ |
181 | 209 | public function valid () |
182 | 210 | { |
183 | - if ($this->debug) error_log(__METHOD__."() returning ".array2string(current($this->files) !== false)); |
|
211 | + if ($this->debug) |
|
212 | + { |
|
213 | + error_log(__METHOD__."() returning ".array2string(current($this->files) !== false)); |
|
214 | + } |
|
184 | 215 | return current($this->files) !== false; |
185 | 216 | } |
186 | 217 | } |