Index: branches/5.2.x/core/units/helpers/language_import_helper.php =================================================================== diff -u -N -r15012 -r15116 --- branches/5.2.x/core/units/helpers/language_import_helper.php (.../language_import_helper.php) (revision 15012) +++ branches/5.2.x/core/units/helpers/language_import_helper.php (.../language_import_helper.php) (revision 15116) @@ -1,6 +1,6 @@ getExportIDs($prefix); + + $sql = 'SELECT ' . $key_field . ' + FROM ' . $this->Application->getUnitOption($prefix, 'TableName') . ' + WHERE ' . $this->Application->getUnitOption($prefix, 'IDField') . ' IN (' . $ids . ')'; + $rs = $this->Conn->QueryRaw($sql); + + if ( $this->Conn->RowCount($rs) ) { + $data = ''; + + while ( ($row = $this->Conn->GetNextRow($rs)) ) { + $data .= ',' . $row[$key_field]; + } + + $data = substr($data, 1); + } + + $this->Conn->Destroy($rs); } - if (!is_array($email_events)) { - $email_events = str_replace(',', "\n", $email_events); - $email_events = preg_replace("/\n+/", "\n", str_replace("\r", '', trim($email_events))); - $email_events = $email_events ? array_map('trim', explode("\n", $email_events)) : Array (); + if ( !is_array($data) ) { + $data = str_replace(',', "\n", $data); + $data = preg_replace("/\n+/", "\n", str_replace("\r", '', trim($data))); + $data = $data ? array_map('trim', explode("\n", $data)) : Array (); } - $this->_exportLimits = Array ('phrases' => $phrases, 'emailevents' => $email_events); + $this->_exportLimits[$prefix] = $data; } /** @@ -1101,4 +1117,48 @@ return array_key_exists($country_id . '-' . $state_iso, $cache) ? $cache[$country_id . '-' . $state_iso] : false; } + + /** + * Returns comma-separated list of IDs, that will be exported + * + * @param string $prefix + * @return string + * @access public + */ + public function getExportIDs($prefix) + { + $ids = $this->Application->RecallVar($prefix . '_selected_ids'); + + if ( $ids ) { + // some records were selected in grid + return $ids; + } + + $tag_params = Array ( + 'grid' => $prefix == 'phrases' ? 'Phrases' : 'Emails', + 'skip_counting' => 1, + 'per_page' => -1 + ); + + $list =& $this->Application->recallObject($prefix, $prefix . '_List', $tag_params); + /* @var $list kDBList */ + + $sql = $list->getCountSQL($list->GetSelectSQL()); + $sql = str_replace('COUNT(*) AS count', $list->TableName . '.' . $list->IDField, $sql); + + $ids = ''; + $rs = $this->Conn->QueryRaw($sql); + + if ( $this->Conn->RowCount($rs) ) { + while ( ($row = $this->Conn->GetNextRow($rs)) ) { + $ids .= ',' . $row[$list->IDField]; + } + + $ids = substr($ids, 1); + } + + $this->Conn->Destroy($rs); + + return $ids; + } } \ No newline at end of file