@@ -27,15 +27,15 @@ discard block |
||
| 27 | 27 | * |
| 28 | 28 | * @param egw_record $_definition |
| 29 | 29 | */ |
| 30 | - public function export( $_stream, importexport_definition $_definition) { |
|
| 30 | + public function export($_stream, importexport_definition $_definition) { |
|
| 31 | 31 | $options = $_definition->plugin_options; |
| 32 | 32 | |
| 33 | 33 | $limit_exception = bo_merge::is_export_limit_excepted(); |
| 34 | 34 | if (!$limit_exception) $export_limit = bo_merge::getExportLimit('calendar'); |
| 35 | 35 | // Custom fields need to be specifically requested |
| 36 | 36 | $cfs = array(); |
| 37 | - foreach($options['mapping'] + (array)$_definition->filter as $key => $label) { |
|
| 38 | - if($key[0] == '#') $cfs[] = substr($key,1); |
|
| 37 | + foreach ($options['mapping'] + (array)$_definition->filter as $key => $label) { |
|
| 38 | + if ($key[0] == '#') $cfs[] = substr($key, 1); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | $query = array( |
@@ -43,48 +43,48 @@ discard block |
||
| 43 | 43 | 'num_rows' => -1, |
| 44 | 44 | 'csv_export' => true |
| 45 | 45 | ); |
| 46 | - switch($options['selection']) |
|
| 46 | + switch ($options['selection']) |
|
| 47 | 47 | { |
| 48 | 48 | case 'criteria': |
| 49 | 49 | $query = array( |
| 50 | 50 | 'start' => $options['criteria']['start'], |
| 51 | - 'end' => strtotime('+1 day',$options['criteria']['end'])-1, |
|
| 51 | + 'end' => strtotime('+1 day', $options['criteria']['end']) - 1, |
|
| 52 | 52 | 'categories' => $options['categories'] ? $options['categories'] : $options['criteria']['categories'], |
| 53 | 53 | //'enum_recuring' => false, // we want the recurring events enumerated for csv export |
| 54 | 54 | 'daywise' => false, |
| 55 | 55 | 'users' => $options['criteria']['owner'], |
| 56 | 56 | 'cfs' => $cfs // Otherwise we shouldn't get any custom fields |
| 57 | 57 | ); |
| 58 | - if(bo_merge::hasExportLimit($export_limit) && !$limit_exception) { |
|
| 58 | + if (bo_merge::hasExportLimit($export_limit) && !$limit_exception) { |
|
| 59 | 59 | $query['offset'] = 0; |
| 60 | 60 | $query['num_rows'] = (int)$export_limit; // ! int of 'no' is 0 |
| 61 | 61 | } |
| 62 | - $events =& $this->bo->search($query); |
|
| 62 | + $events = & $this->bo->search($query); |
|
| 63 | 63 | break; |
| 64 | 64 | case 'search_results': |
| 65 | - $states = $GLOBALS['egw']->session->appsession('session_data','calendar'); |
|
| 66 | - if($states['view'] == 'listview') { |
|
| 67 | - $query = $GLOBALS['egw']->session->appsession('calendar_list','calendar'); |
|
| 68 | - $query['num_rows'] = -1; // all |
|
| 69 | - $query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session |
|
| 65 | + $states = $GLOBALS['egw']->session->appsession('session_data', 'calendar'); |
|
| 66 | + if ($states['view'] == 'listview') { |
|
| 67 | + $query = $GLOBALS['egw']->session->appsession('calendar_list', 'calendar'); |
|
| 68 | + $query['num_rows'] = -1; // all |
|
| 69 | + $query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session |
|
| 70 | 70 | $query['start'] = 0; |
| 71 | 71 | $query['cfs'] = $cfs; |
| 72 | 72 | |
| 73 | - if(bo_merge::hasExportLimit($export_limit) && !$limit_exception) { |
|
| 73 | + if (bo_merge::hasExportLimit($export_limit) && !$limit_exception) { |
|
| 74 | 74 | $query['num_rows'] = (int)$export_limit; // ! int of 'no' is 0 |
| 75 | 75 | } |
| 76 | 76 | $ui = new calendar_uilist(); |
| 77 | 77 | $ui->get_rows($query, $events, $unused); |
| 78 | 78 | } else { |
| 79 | - $query = $GLOBALS['egw']->session->appsession('session_data','calendar'); |
|
| 79 | + $query = $GLOBALS['egw']->session->appsession('session_data', 'calendar'); |
|
| 80 | 80 | $query['users'] = explode(',', $query['owner']); |
| 81 | 81 | $query['num_rows'] = -1; |
| 82 | - if(bo_merge::hasExportLimit($export_limit) && !$limit_exception) { |
|
| 83 | - $query['num_rows'] = (int)$export_limit; // ! int of 'no' is 0 |
|
| 82 | + if (bo_merge::hasExportLimit($export_limit) && !$limit_exception) { |
|
| 83 | + $query['num_rows'] = (int)$export_limit; // ! int of 'no' is 0 |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | $events = array(); |
| 87 | - switch($states['view']) { |
|
| 87 | + switch ($states['view']) { |
|
| 88 | 88 | case 'month': |
| 89 | 89 | $query += $this->get_query_month($states); |
| 90 | 90 | break; |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | default: |
| 99 | 99 | // Let UI set the date ranges |
| 100 | 100 | $ui = new calendar_uiviews($query); |
| 101 | - if(method_exists($ui, $states['view'])) |
|
| 101 | + if (method_exists($ui, $states['view'])) |
|
| 102 | 102 | { |
| 103 | 103 | ob_start(); |
| 104 | 104 | $ui->$states['view'](); |
@@ -122,35 +122,35 @@ discard block |
||
| 122 | 122 | $filter = $_definition->filter; |
| 123 | 123 | |
| 124 | 124 | // Handle ranges |
| 125 | - foreach($filter as $field => $value) |
|
| 125 | + foreach ($filter as $field => $value) |
|
| 126 | 126 | { |
| 127 | - if($field == 'filter' && $value) |
|
| 127 | + if ($field == 'filter' && $value) |
|
| 128 | 128 | { |
| 129 | 129 | $query['filter'] = $value; |
| 130 | 130 | continue; |
| 131 | 131 | } |
| 132 | - if(!is_array($value) || (!$value['from'] && !$value['to'])) |
|
| 132 | + if (!is_array($value) || (!$value['from'] && !$value['to'])) |
|
| 133 | 133 | { |
| 134 | 134 | $query['query']["cal_$field"] = $value; |
| 135 | 135 | continue; |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | // Ranges are inclusive, so should be provided that way (from 2 to 10 includes 2 and 10) |
| 139 | - if($value['from']) $query['sql_filter'][] = "cal_$field >= " . (int)$value['from']; |
|
| 140 | - if($value['to']) $query['sql_filter'][] = "cal_$field <= " . (int)$value['to']; |
|
| 139 | + if ($value['from']) $query['sql_filter'][] = "cal_$field >= ".(int)$value['from']; |
|
| 140 | + if ($value['to']) $query['sql_filter'][] = "cal_$field <= ".(int)$value['to']; |
|
| 141 | 141 | |
| 142 | 142 | } |
| 143 | - if($query['sql_filter'] && is_array($query['sql_filter'])) |
|
| 143 | + if ($query['sql_filter'] && is_array($query['sql_filter'])) |
|
| 144 | 144 | { |
| 145 | 145 | // Set as an extra parameter |
| 146 | - $sql_filter = implode(' AND ',$query['sql_filter']); |
|
| 146 | + $sql_filter = implode(' AND ', $query['sql_filter']); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | case 'all': |
| 150 | 150 | $events = $this->bo->search($query + array( |
| 151 | 151 | 'offset' => 0, |
| 152 | 152 | 'order' => 'cal_start', |
| 153 | - ),$sql_filter); |
|
| 153 | + ), $sql_filter); |
|
| 154 | 154 | break; |
| 155 | 155 | } |
| 156 | 156 | |
@@ -167,24 +167,24 @@ discard block |
||
| 167 | 167 | // Get rid of yearly recurring events that don't belong |
| 168 | 168 | //if($options['selection']['select'] == 'criteria' && ($event['start'] > $query['end'] || $event['end'] < $query['start'])) continue; |
| 169 | 169 | // Add in participants |
| 170 | - if($options['mapping']['participants']) { |
|
| 171 | - $event['participants'] = implode(", ",$this->bo->participants($event,true)); |
|
| 170 | + if ($options['mapping']['participants']) { |
|
| 171 | + $event['participants'] = implode(", ", $this->bo->participants($event, true)); |
|
| 172 | 172 | } |
| 173 | 173 | if (is_array($event)) |
| 174 | 174 | { |
| 175 | 175 | $record->set_record($event); |
| 176 | - if($options['mapping']['recurrence']) { |
|
| 176 | + if ($options['mapping']['recurrence']) { |
|
| 177 | 177 | $record->recurrence = $recurrence[$record->recur_type]; |
| 178 | - if($record->recur_type != MCAL_RECUR_NONE) $record->recurrence .= ' / '. $record->recur_interval; |
|
| 178 | + if ($record->recur_type != MCAL_RECUR_NONE) $record->recurrence .= ' / '.$record->recur_interval; |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | // Standard stuff |
| 182 | - if($options['convert']) { |
|
| 182 | + if ($options['convert']) { |
|
| 183 | 183 | importexport_export_csv::convert($record, $convert_fields, 'calendar', $this->selects); |
| 184 | 184 | } else { |
| 185 | 185 | // Implode arrays, so they don't say 'Array' |
| 186 | - foreach($record->get_record_array() as $key => $value) { |
|
| 187 | - if(is_array($value)) $record->$key = implode(',', $value); |
|
| 186 | + foreach ($record->get_record_array() as $key => $value) { |
|
| 187 | + if (is_array($value)) $record->$key = implode(',', $value); |
|
| 188 | 188 | } |
| 189 | 189 | } |
| 190 | 190 | $export_object->export_record($record); |
@@ -237,8 +237,8 @@ discard block |
||
| 237 | 237 | * |
| 238 | 238 | */ |
| 239 | 239 | public function get_selectors_etpl($definition = null) { |
| 240 | - $states = $GLOBALS['egw']->session->appsession('session_data','calendar'); |
|
| 241 | - switch($states['view']) { |
|
| 240 | + $states = $GLOBALS['egw']->session->appsession('session_data', 'calendar'); |
|
| 241 | + switch ($states['view']) { |
|
| 242 | 242 | case 'month': |
| 243 | 243 | $query = $this->get_query_month($states); |
| 244 | 244 | break; |
@@ -250,32 +250,32 @@ discard block |
||
| 250 | 250 | $query = $this->get_query_day($states); |
| 251 | 251 | break; |
| 252 | 252 | } |
| 253 | - $start= new egw_time($query['start']); |
|
| 253 | + $start = new egw_time($query['start']); |
|
| 254 | 254 | $end = new egw_time($query['end']); |
| 255 | 255 | if ($states['view'] == 'listview') |
| 256 | 256 | { |
| 257 | - $list = $GLOBALS['egw']->session->appsession('calendar_list','calendar'); |
|
| 257 | + $list = $GLOBALS['egw']->session->appsession('calendar_list', 'calendar'); |
|
| 258 | 258 | |
| 259 | 259 | // Use UI to get dates |
| 260 | 260 | $ui = new calendar_uilist(); |
| 261 | - $list['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session |
|
| 262 | - $ui->get_rows($list,$rows,$readonlys); |
|
| 261 | + $list['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session |
|
| 262 | + $ui->get_rows($list, $rows, $readonlys); |
|
| 263 | 263 | $start = $ui->first ? $ui->first : new egw_time($ui->date); |
| 264 | 264 | $end = $ui->last; |
| 265 | 265 | |
| 266 | 266 | // Special handling |
| 267 | - if($list['filter'] == 'all') $start = $end = null; |
|
| 268 | - if($list['filter'] == 'before') |
|
| 267 | + if ($list['filter'] == 'all') $start = $end = null; |
|
| 268 | + if ($list['filter'] == 'before') |
|
| 269 | 269 | { |
| 270 | 270 | $end = $start; |
| 271 | 271 | $start = null; |
| 272 | 272 | } |
| 273 | 273 | $ui = null; |
| 274 | 274 | } |
| 275 | - elseif(!$end) |
|
| 275 | + elseif (!$end) |
|
| 276 | 276 | { |
| 277 | - $end = '+1 ' . $states['view']; |
|
| 278 | - $end = strtotime($end, $start->format('ts'))-1; |
|
| 277 | + $end = '+1 '.$states['view']; |
|
| 278 | + $end = strtotime($end, $start->format('ts')) - 1; |
|
| 279 | 279 | } |
| 280 | 280 | $prefs = unserialize($GLOBALS['egw_info']['user']['preferences']['importexport'][$definition->definition_id]); |
| 281 | 281 | $data = array( |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | 'criteria' => array( |
| 287 | 287 | 'start' => is_object($start) ? $start->format('ts') : $start, |
| 288 | 288 | 'end' => is_object($end) ? $end->format('ts') : $end, |
| 289 | - 'owner' => is_array($states['owner']) ? $states['owner'] : explode(',',$states['owner']) |
|
| 289 | + 'owner' => is_array($states['owner']) ? $states['owner'] : explode(',', $states['owner']) |
|
| 290 | 290 | ) |
| 291 | 291 | ), |
| 292 | 292 | 'sel_options' => array( |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | ) |
| 295 | 295 | ); |
| 296 | 296 | // Pass current owner labels |
| 297 | - foreach($data['content']['criteria']['owner'] as $owner) |
|
| 297 | + foreach ($data['content']['criteria']['owner'] as $owner) |
|
| 298 | 298 | { |
| 299 | 299 | $data['sel_options']['owner'][] = array( |
| 300 | 300 | 'id' => $owner, |
@@ -312,8 +312,8 @@ discard block |
||
| 312 | 312 | public static function get_query_month($states) |
| 313 | 313 | { |
| 314 | 314 | $timespan = array( |
| 315 | - 'start' => mktime(0,0,0,$states['month'],1,$states['year']), |
|
| 316 | - 'end' => mktime(0,0,0,$states['month']+1,1,$states['year'])-1 |
|
| 315 | + 'start' => mktime(0, 0, 0, $states['month'], 1, $states['year']), |
|
| 316 | + 'end' => mktime(0, 0, 0, $states['month'] + 1, 1, $states['year']) - 1 |
|
| 317 | 317 | ); |
| 318 | 318 | return $timespan; |
| 319 | 319 | } |
@@ -331,24 +331,24 @@ discard block |
||
| 331 | 331 | if ($states['view'] == 'week' && $days == 4) // next 4 days view |
| 332 | 332 | { |
| 333 | 333 | $query['start'] = $this->bo->date2ts($states['date']); |
| 334 | - $query['end'] = strtotime("+$days days",$query['start']) - 1; |
|
| 334 | + $query['end'] = strtotime("+$days days", $query['start']) - 1; |
|
| 335 | 335 | } |
| 336 | 336 | else |
| 337 | 337 | { |
| 338 | - $query['start'] = $ui->datetime->get_weekday_start($states['year'],$states['month'],$states['day']); |
|
| 338 | + $query['start'] = $ui->datetime->get_weekday_start($states['year'], $states['month'], $states['day']); |
|
| 339 | 339 | if ($days == 5) // no weekend-days |
| 340 | 340 | { |
| 341 | - switch($ui->cal_prefs['weekdaystarts']) |
|
| 341 | + switch ($ui->cal_prefs['weekdaystarts']) |
|
| 342 | 342 | { |
| 343 | 343 | case 'Saturday': |
| 344 | - $query['start'] = strtotime("+2 days",$query['start']); |
|
| 344 | + $query['start'] = strtotime("+2 days", $query['start']); |
|
| 345 | 345 | break; |
| 346 | 346 | case 'Sunday': |
| 347 | - $query['start'] = strtotime("+1 day",$query['start']); |
|
| 347 | + $query['start'] = strtotime("+1 day", $query['start']); |
|
| 348 | 348 | break; |
| 349 | 349 | } |
| 350 | 350 | } |
| 351 | - $query['end'] = strtotime($states['view'] == 'week' ? "+$days days" : "+{$ui->cal_prefs['multiple_weeks']} weeks",$query['start']) - 1; |
|
| 351 | + $query['end'] = strtotime($states['view'] == 'week' ? "+$days days" : "+{$ui->cal_prefs['multiple_weeks']} weeks", $query['start']) - 1; |
|
| 352 | 352 | } |
| 353 | 353 | return $query; |
| 354 | 354 | } |
@@ -358,7 +358,7 @@ discard block |
||
| 358 | 358 | $query = array(); |
| 359 | 359 | $bo = new calendar_bo(); |
| 360 | 360 | $query['start'] = $bo->date2ts((string)$states['date']); |
| 361 | - $query['end'] = $query['start']+DAY_s-1; |
|
| 361 | + $query['end'] = $query['start'] + DAY_s - 1; |
|
| 362 | 362 | return $query; |
| 363 | 363 | } |
| 364 | 364 | |
@@ -407,17 +407,17 @@ discard block |
||
| 407 | 407 | ); |
| 408 | 408 | $filters = array_reverse($filters, true); |
| 409 | 409 | |
| 410 | - foreach($filters as $field_name => &$settings) |
|
| 410 | + foreach ($filters as $field_name => &$settings) |
|
| 411 | 411 | { |
| 412 | 412 | // Can't filter on a custom field |
| 413 | - if(strpos($field_name, '#') === 0) |
|
| 413 | + if (strpos($field_name, '#') === 0) |
|
| 414 | 414 | { |
| 415 | 415 | unset($filters[$field_name]); |
| 416 | 416 | continue; |
| 417 | 417 | } |
| 418 | 418 | |
| 419 | 419 | // Pass on select options |
| 420 | - if($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name]; |
|
| 420 | + if ($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name]; |
|
| 421 | 421 | } |
| 422 | 422 | |
| 423 | 423 | } |