Index: branches/unlabeled/unlabeled-1.17.2/kernel/units/general/cat_dbitem_export.php
===================================================================
diff -u -r4331 -r5352
--- branches/unlabeled/unlabeled-1.17.2/kernel/units/general/cat_dbitem_export.php (.../cat_dbitem_export.php) (revision 4331)
+++ branches/unlabeled/unlabeled-1.17.2/kernel/units/general/cat_dbitem_export.php (.../cat_dbitem_export.php) (revision 5352)
@@ -51,6 +51,12 @@
*/
var $filePointer = null;
+ /**
+ * Custom fields definition of current item
+ *
+ * @var Array
+ */
+ var $customFields = Array();
function kCatDBItemExportHelper()
{
@@ -282,6 +288,7 @@
}
else {
foreach ($check_fields as $check_field) {
+ $check_field = preg_replace('/^cust_(.*)/', 'Custom_\\1', $check_field);
if (!in_array($check_field, $this->exportOptions['ExportColumns'])) {
$object->setError('ExportColumns', 'required');
$ret = false;
@@ -354,29 +361,35 @@
fclose($this->filePointer);
}
+ function getCustomSQL()
+ {
+ $ml_formatter =& $this->Application->recallObject('kMultiLanguage');
+
+ $custom_sql = '';
+ foreach ($this->customFields as $custom_id => $custom_name) {
+ $custom_sql .= 'custom_data.'.$ml_formatter->LangFieldName('cust_'.$custom_id).' AS cust_'.$custom_name.', ';
+ }
+
+ return preg_replace('/(.*), /', '\\1', $custom_sql);
+ }
+
function getExportSQL($count_only = false)
{
if ($this->exportOptions['export_ids'] === false)
{
// get links from current category & all it's subcategories
$join_clauses = Array();
- $custom_sql = '';
- $custom_table = $this->Application->getUnitOption($this->curItem->Prefix.'-cdata', 'TableName');
-
- if ($custom_table) {
- $ml_formatter =& $this->Application->recallObject('kMultiLanguage');
- $custom_fields = $this->Application->getUnitOption($this->curItem->Prefix, 'CustomFields');
-
- foreach ($custom_fields as $custom_id => $custom_name) {
- $custom_sql .= 'custom_data.'.$ml_formatter->LangFieldName('cust_'.$custom_id).' AS cust_'.$custom_name.',';
- }
+ $custom_sql = $this->getCustomSQL();
+ if ($custom_sql) {
+ $custom_table = $this->Application->getUnitOption($this->curItem->Prefix.'-cdata', 'TableName');
$join_clauses[$custom_table.' custom_data'] = 'custom_data.ResourceId = item_table.ResourceId';
}
+
$join_clauses[TABLE_PREFIX.'CategoryItems ci'] = 'ci.ItemResourceId = item_table.ResourceId';
$join_clauses[TABLE_PREFIX.'Category c'] = 'c.CategoryId = ci.CategoryId';
- $sql = 'SELECT item_table.*, '.$custom_sql.' ci.CategoryId
+ $sql = 'SELECT item_table.*, ci.CategoryId'.($custom_sql ? ', '.$custom_sql : '').'
FROM '.$this->curItem->TableName.' item_table';
foreach ($join_clauses as $table_name => $join_expression) {
@@ -425,7 +438,7 @@
$this->exportOptions = $this->loadOptions($event);
$this->exportFields = $this->exportOptions['ExportColumns'];
$this->curItem =& $event->getObject( Array('skip_autoload' => true) );
-
+ $this->customFields = $this->Application->getUnitOption($event->Prefix, 'CustomFields');
$this->openFile($event);
if ($this->exportOptions['start_from'] == 0) // first export step
@@ -636,7 +649,8 @@
break;
}
$this->curItem->Clear();
-
+ $this->customFields = $this->Application->getUnitOption($event->Prefix, 'CustomFields');
+
if (isset($record_data)) {
$this->setImportData($record_data);
}
@@ -739,7 +753,15 @@
if (count($load_keys)) {
$where_clause = '';
foreach ($load_keys as $field_name => $field_value) {
- $where_clause .= '(item_table.`'.$field_name.'` = '.$this->Conn->qstr($field_value).') AND ';
+ if (preg_match('/^cust_(.*)/', $field_name, $regs)) {
+ $custom_id = array_search($regs[1], $this->customFields);
+ $field_name = 'l'.$this->Application->GetVar('m_lang').'_cust_'.$custom_id;
+ $where_clause .= '(custom_data.`'.$field_name.'` = '.$this->Conn->qstr($field_value).') AND ';
+ }
+ else {
+ $where_clause .= '(item_table.`'.$field_name.'` = '.$this->Conn->qstr($field_value).') AND ';
+ }
+
}
$where_clause = preg_replace('/(.*) AND $/', '\\1', $where_clause);
@@ -750,9 +772,11 @@
$parent_path = $this->getParentPath($category_id);
$where_clause = '(c.ParentPath LIKE "'.$parent_path.'%") AND '.$where_clause;
}
-
+
+ $cdata_table = $this->Application->getUnitOption($event->Prefix.'-cdata', 'TableName');
$sql = 'SELECT '.$this->curItem->IDField.'
FROM '.$this->curItem->TableName.' item_table
+ LEFT JOIN '.$cdata_table.' custom_data ON custom_data.ResourceId = item_table.ResourceId
LEFT JOIN '.TABLE_PREFIX.'CategoryItems ci ON ci.ItemResourceId = item_table.ResourceId
LEFT JOIN '.TABLE_PREFIX.'Category c ON c.CategoryId = ci.CategoryId
WHERE '.$where_clause;
Index: branches/unlabeled/unlabeled-1.3.10/kernel/admin_templates/incs/export.js
===================================================================
diff -u -r4359 -r5352
--- branches/unlabeled/unlabeled-1.3.10/kernel/admin_templates/incs/export.js (.../export.js) (revision 4359)
+++ branches/unlabeled/unlabeled-1.3.10/kernel/admin_templates/incs/export.js (.../export.js) (revision 5352)
@@ -73,7 +73,12 @@
}
else {
// alert('progress: '+$progress+' ('+$http_request.responseText+')');
- alert($phrase_ResponceError);
+ if (typeof($Debugger) != 'undefined') {
+ alert('DEBUG_MODE: error in ajax responce' + "\n" + $http_request.responseText);
+ }
+ else {
+ alert($phrase_ResponceError);
+ }
}
}
}
Index: branches/unlabeled/unlabeled-1.17.2/core/units/general/cat_dbitem_export.php
===================================================================
diff -u -r4331 -r5352
--- branches/unlabeled/unlabeled-1.17.2/core/units/general/cat_dbitem_export.php (.../cat_dbitem_export.php) (revision 4331)
+++ branches/unlabeled/unlabeled-1.17.2/core/units/general/cat_dbitem_export.php (.../cat_dbitem_export.php) (revision 5352)
@@ -51,6 +51,12 @@
*/
var $filePointer = null;
+ /**
+ * Custom fields definition of current item
+ *
+ * @var Array
+ */
+ var $customFields = Array();
function kCatDBItemExportHelper()
{
@@ -282,6 +288,7 @@
}
else {
foreach ($check_fields as $check_field) {
+ $check_field = preg_replace('/^cust_(.*)/', 'Custom_\\1', $check_field);
if (!in_array($check_field, $this->exportOptions['ExportColumns'])) {
$object->setError('ExportColumns', 'required');
$ret = false;
@@ -354,29 +361,35 @@
fclose($this->filePointer);
}
+ function getCustomSQL()
+ {
+ $ml_formatter =& $this->Application->recallObject('kMultiLanguage');
+
+ $custom_sql = '';
+ foreach ($this->customFields as $custom_id => $custom_name) {
+ $custom_sql .= 'custom_data.'.$ml_formatter->LangFieldName('cust_'.$custom_id).' AS cust_'.$custom_name.', ';
+ }
+
+ return preg_replace('/(.*), /', '\\1', $custom_sql);
+ }
+
function getExportSQL($count_only = false)
{
if ($this->exportOptions['export_ids'] === false)
{
// get links from current category & all it's subcategories
$join_clauses = Array();
- $custom_sql = '';
- $custom_table = $this->Application->getUnitOption($this->curItem->Prefix.'-cdata', 'TableName');
-
- if ($custom_table) {
- $ml_formatter =& $this->Application->recallObject('kMultiLanguage');
- $custom_fields = $this->Application->getUnitOption($this->curItem->Prefix, 'CustomFields');
-
- foreach ($custom_fields as $custom_id => $custom_name) {
- $custom_sql .= 'custom_data.'.$ml_formatter->LangFieldName('cust_'.$custom_id).' AS cust_'.$custom_name.',';
- }
+ $custom_sql = $this->getCustomSQL();
+ if ($custom_sql) {
+ $custom_table = $this->Application->getUnitOption($this->curItem->Prefix.'-cdata', 'TableName');
$join_clauses[$custom_table.' custom_data'] = 'custom_data.ResourceId = item_table.ResourceId';
}
+
$join_clauses[TABLE_PREFIX.'CategoryItems ci'] = 'ci.ItemResourceId = item_table.ResourceId';
$join_clauses[TABLE_PREFIX.'Category c'] = 'c.CategoryId = ci.CategoryId';
- $sql = 'SELECT item_table.*, '.$custom_sql.' ci.CategoryId
+ $sql = 'SELECT item_table.*, ci.CategoryId'.($custom_sql ? ', '.$custom_sql : '').'
FROM '.$this->curItem->TableName.' item_table';
foreach ($join_clauses as $table_name => $join_expression) {
@@ -425,7 +438,7 @@
$this->exportOptions = $this->loadOptions($event);
$this->exportFields = $this->exportOptions['ExportColumns'];
$this->curItem =& $event->getObject( Array('skip_autoload' => true) );
-
+ $this->customFields = $this->Application->getUnitOption($event->Prefix, 'CustomFields');
$this->openFile($event);
if ($this->exportOptions['start_from'] == 0) // first export step
@@ -636,7 +649,8 @@
break;
}
$this->curItem->Clear();
-
+ $this->customFields = $this->Application->getUnitOption($event->Prefix, 'CustomFields');
+
if (isset($record_data)) {
$this->setImportData($record_data);
}
@@ -739,7 +753,15 @@
if (count($load_keys)) {
$where_clause = '';
foreach ($load_keys as $field_name => $field_value) {
- $where_clause .= '(item_table.`'.$field_name.'` = '.$this->Conn->qstr($field_value).') AND ';
+ if (preg_match('/^cust_(.*)/', $field_name, $regs)) {
+ $custom_id = array_search($regs[1], $this->customFields);
+ $field_name = 'l'.$this->Application->GetVar('m_lang').'_cust_'.$custom_id;
+ $where_clause .= '(custom_data.`'.$field_name.'` = '.$this->Conn->qstr($field_value).') AND ';
+ }
+ else {
+ $where_clause .= '(item_table.`'.$field_name.'` = '.$this->Conn->qstr($field_value).') AND ';
+ }
+
}
$where_clause = preg_replace('/(.*) AND $/', '\\1', $where_clause);
@@ -750,9 +772,11 @@
$parent_path = $this->getParentPath($category_id);
$where_clause = '(c.ParentPath LIKE "'.$parent_path.'%") AND '.$where_clause;
}
-
+
+ $cdata_table = $this->Application->getUnitOption($event->Prefix.'-cdata', 'TableName');
$sql = 'SELECT '.$this->curItem->IDField.'
FROM '.$this->curItem->TableName.' item_table
+ LEFT JOIN '.$cdata_table.' custom_data ON custom_data.ResourceId = item_table.ResourceId
LEFT JOIN '.TABLE_PREFIX.'CategoryItems ci ON ci.ItemResourceId = item_table.ResourceId
LEFT JOIN '.TABLE_PREFIX.'Category c ON c.CategoryId = ci.CategoryId
WHERE '.$where_clause;
Index: branches/unlabeled/unlabeled-1.8.2/core/units/general/helpers/permissions_helper.php
===================================================================
diff -u -r5188 -r5352
--- branches/unlabeled/unlabeled-1.8.2/core/units/general/helpers/permissions_helper.php (.../permissions_helper.php) (revision 5188)
+++ branches/unlabeled/unlabeled-1.8.2/core/units/general/helpers/permissions_helper.php (.../permissions_helper.php) (revision 5352)
@@ -186,7 +186,7 @@
continue;
}
$perm_name = $item_prefix.'.'.$perm_mapping[$perm_name];
- $this->showDebug('Event '.$event->Name.' permission(-s): '.$perm_name.'');
+ $this->showDebug('Event '.$event->Name.' permission(-s): '.$perm_name.'', Array());
$perm_status = $this->CheckPermission($perm_name, 0, $category_id);
if ($perm_status) {
@@ -208,9 +208,10 @@
return $perm_status;
}
- function showDebug($text)
+ function showDebug($text, $params)
{
- if (!$this->Application->isDebugMode()) return true;
+ $is_ajax = $this->Application->GetVar('ajax') == 'yes' || isset($params['ajax']) || isset($params['tab_init']);
+ if (!$this->Application->isDebugMode() || $is_ajax) return true;
echo $text.'
';
}
@@ -220,7 +221,7 @@
$permission_groups = getArrayValue($params, 'permissions');
if ($permission_groups) {
- $this->showDebug('Tag '.$tag_name.' permission(-s): '.$permission_groups.'');
+ $this->showDebug('Tag '.$tag_name.' permission(-s): '.$permission_groups.'', $params);
$permission_groups = explode('|', $permission_groups);
$group_has_permission = false;
foreach ($permission_groups as $permission_group) {
@@ -238,7 +239,7 @@
return false;
}
elseif ($perm_event) {
- $this->showDebug('Tag '.$tag_name.' permission_event: '.$perm_event.'');
+ $this->showDebug('Tag '.$tag_name.' permission_event: '.$perm_event.'', $params);
list($prefix, $event) = explode(':', $perm_event);
$event_handler =& $this->Application->recallObject($prefix.'_EventHandler');
return $event_handler->CheckPermission( new kEvent($perm_event) );
Index: branches/unlabeled/unlabeled-1.8.2/kernel/units/general/helpers/permissions_helper.php
===================================================================
diff -u -r5188 -r5352
--- branches/unlabeled/unlabeled-1.8.2/kernel/units/general/helpers/permissions_helper.php (.../permissions_helper.php) (revision 5188)
+++ branches/unlabeled/unlabeled-1.8.2/kernel/units/general/helpers/permissions_helper.php (.../permissions_helper.php) (revision 5352)
@@ -186,7 +186,7 @@
continue;
}
$perm_name = $item_prefix.'.'.$perm_mapping[$perm_name];
- $this->showDebug('Event '.$event->Name.' permission(-s): '.$perm_name.'');
+ $this->showDebug('Event '.$event->Name.' permission(-s): '.$perm_name.'', Array());
$perm_status = $this->CheckPermission($perm_name, 0, $category_id);
if ($perm_status) {
@@ -208,9 +208,10 @@
return $perm_status;
}
- function showDebug($text)
+ function showDebug($text, $params)
{
- if (!$this->Application->isDebugMode()) return true;
+ $is_ajax = $this->Application->GetVar('ajax') == 'yes' || isset($params['ajax']) || isset($params['tab_init']);
+ if (!$this->Application->isDebugMode() || $is_ajax) return true;
echo $text.'
';
}
@@ -220,7 +221,7 @@
$permission_groups = getArrayValue($params, 'permissions');
if ($permission_groups) {
- $this->showDebug('Tag '.$tag_name.' permission(-s): '.$permission_groups.'');
+ $this->showDebug('Tag '.$tag_name.' permission(-s): '.$permission_groups.'', $params);
$permission_groups = explode('|', $permission_groups);
$group_has_permission = false;
foreach ($permission_groups as $permission_group) {
@@ -238,7 +239,7 @@
return false;
}
elseif ($perm_event) {
- $this->showDebug('Tag '.$tag_name.' permission_event: '.$perm_event.'');
+ $this->showDebug('Tag '.$tag_name.' permission_event: '.$perm_event.'', $params);
list($prefix, $event) = explode(':', $perm_event);
$event_handler =& $this->Application->recallObject($prefix.'_EventHandler');
return $event_handler->CheckPermission( new kEvent($perm_event) );