mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-25 01:13:25 +01:00
Optimizations:
- Only load bo once in egw_record, and re-use it - Only load projects if requested in the export definition, and do it all at once
This commit is contained in:
parent
a9119e5eeb
commit
5d77dbfdc9
@ -20,7 +20,7 @@ class infolog_egw_record implements importexport_iface_egw_record
|
||||
{
|
||||
private $identifier = '';
|
||||
private $record = array();
|
||||
private $bo;
|
||||
private static $bo;
|
||||
|
||||
// Used in conversions
|
||||
static $types = array(
|
||||
@ -39,9 +39,9 @@ class infolog_egw_record implements importexport_iface_egw_record
|
||||
*/
|
||||
public function __construct( $_identifier='' ){
|
||||
$this->identifier = $_identifier;
|
||||
$this->bo = new infolog_bo();
|
||||
if(self::$bo == null) self::$bo = new infolog_bo();
|
||||
if($_identifier) {
|
||||
$this->set_record($this->bo->read($this->identifier));
|
||||
$this->set_record(self::$bo->read($this->identifier));
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,14 +96,6 @@ class infolog_egw_record implements importexport_iface_egw_record
|
||||
*/
|
||||
public function set_record(array $_record){
|
||||
$this->record = $_record;
|
||||
// Check for linked project ID
|
||||
$links = egw_link::get_links('infolog', $_record['info_id'], 'projectmanager');
|
||||
foreach($links as $link_id => $app_id) {
|
||||
$this->record['pm_id'] = $app_id;
|
||||
$this->record['project'] = egw_link::title('projectmanager', $app_id);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -158,7 +150,6 @@ class infolog_egw_record implements importexport_iface_egw_record
|
||||
*
|
||||
*/
|
||||
public function __destruct() {
|
||||
unset ($this->bo);
|
||||
}
|
||||
|
||||
} // end of egw_addressbook_record
|
||||
|
@ -37,21 +37,41 @@ class infolog_export_csv implements importexport_iface_export_plugin {
|
||||
if($field[0] == '#') $query['custom_fields'][] = $field;
|
||||
}
|
||||
|
||||
$ids = array();
|
||||
if ($options['selection'] == 'search') {
|
||||
$query = array_merge($GLOBALS['egw']->session->appsession('session_data','infolog'), $query);
|
||||
$query['num_rows'] = -1; // all
|
||||
$selection = $bo->search($query);
|
||||
$ids = array_keys($selection);
|
||||
}
|
||||
elseif ( $options['selection'] == 'all' ) {
|
||||
$query['num_rows'] = -1;
|
||||
$selection = $bo->search($query);
|
||||
$ids = array_keys($selection);
|
||||
} else {
|
||||
$selection = explode(',',$options['selection']);
|
||||
$ids = $selection = explode(',',$options['selection']);
|
||||
}
|
||||
|
||||
if($ids && ($options['mapping']['pm_id'] || $options['mapping']['project']))
|
||||
{
|
||||
$projects = egw_link::get_links_multiple('infolog', $ids, true, 'projectmanager');
|
||||
foreach($projects as $id => $links)
|
||||
{
|
||||
if(!is_array($selection[$id])) break;
|
||||
$selection[$id]['pm_id'] = current($links);
|
||||
$selection[$id]['project'] = egw_link::title('projectmanager', $selection[$id]['pm_id']);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($selection as $_identifier) {
|
||||
if(!is_array($_identifier)) {
|
||||
$record = new infolog_egw_record($_identifier);
|
||||
|
||||
if($project = $projects[$record->info_id])
|
||||
{
|
||||
$record->pm_id = current($project);
|
||||
$record->project = egw_link::title('projectmanager', $record->pm_id);
|
||||
}
|
||||
} else {
|
||||
$record = new infolog_egw_record();
|
||||
$record->set_record($_identifier);
|
||||
@ -69,6 +89,7 @@ class infolog_export_csv implements importexport_iface_export_plugin {
|
||||
$export_object->export_record($record);
|
||||
unset($record);
|
||||
}
|
||||
return $export_object;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user