Index: branches/5.3.x/core/kernel/db/cat_event_handler.php
===================================================================
diff -u -N -r15677 -r15698
--- branches/5.3.x/core/kernel/db/cat_event_handler.php (.../cat_event_handler.php) (revision 15677)
+++ branches/5.3.x/core/kernel/db/cat_event_handler.php (.../cat_event_handler.php) (revision 15698)
@@ -1,6 +1,6 @@
Set($event->getPrefixSpecial() . '_id', $object->GetID());
- $use_pending_editing = $this->Application->getUnitOption($event->Prefix, 'UsePendingEditing');
+ $use_pending_editing = $event->getUnitConfig()->getUsePendingEditing();
if ( $use_pending_editing && $event->Special != 'original' ) {
$this->Application->SetVar($event->Prefix . '.original_id', $object->GetDBField('OrgId'));
@@ -409,13 +409,15 @@
$type_clauses['displayed']['include'] = '';
$displayed = $this->Application->GetVar($event->Prefix.'_displayed_ids');
+
if ($displayed) {
- $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField');
+ $id_field = $event->getUnitConfig()->getIDField();
$type_clauses['displayed']['except'] = '%1$s.'.$id_field.' NOT IN ('.$displayed.')';
}
else {
$type_clauses['displayed']['except'] = '';
}
+
$type_clauses['displayed']['having_filter'] = false;
if (in_array('search', $types) || in_array('search', $except_types)) {
@@ -440,8 +442,8 @@
$object = $event->getObject();
/* @var $object kDBList */
- $search_sql = ' FROM ' . TABLE_PREFIX . 'ses_' . $this->Application->GetSID() . '_' . TABLE_PREFIX . 'Search
- search_result JOIN %1$s ON %1$s.ResourceId = search_result.ResourceId';
+ $search_sql = ' FROM ' . TABLE_PREFIX . 'ses_' . $this->Application->GetSID() . '_' . TABLE_PREFIX . 'Search search_result
+ JOIN %1$s ON %1$s.ResourceId = search_result.ResourceId';
$sql = str_replace('FROM %1$s', $search_sql, $object->GetPlainSelectSQL());
$object->SetSelectSQL($sql);
@@ -454,8 +456,8 @@
}
if (in_array('related', $types) || in_array('related', $except_types)) {
-
$related_to = $event->getEventParam('related_to');
+
if (!$related_to) {
$related_prefix = $event->Prefix;
}
@@ -466,20 +468,22 @@
$related_prefix = $this->Conn->GetOne($sql);
}
- $rel_table = $this->Application->getUnitOption('rel', 'TableName');
- $item_type = (int)$this->Application->getUnitOption($event->Prefix, 'ItemType');
+ $rel_table = $this->Application->getUnitConfig('rel')->getTableName();
+ $item_type = (int)$event->getUnitConfig()->getItemType();
if ($item_type == 0) {
trigger_error('ItemType not defined for prefix ' . $event->Prefix . '', E_USER_WARNING);
}
// process case, then this list is called inside another list
$prefix_special = $event->getEventParam('PrefixSpecial');
+
if (!$prefix_special) {
$prefix_special = $this->Application->Parser->GetParam('PrefixSpecial');
}
$id = false;
+
if ($prefix_special !== false) {
$processed_prefix = $this->Application->processPrefix($prefix_special);
if ($processed_prefix['prefix'] == $related_prefix) {
@@ -538,14 +542,16 @@
$type_clauses['related']['include'] = '0';
$type_clauses['related']['except'] = '1';
}
+
$type_clauses['related']['having_filter'] = false;
}
if (in_array('favorites', $types) || in_array('favorites', $except_types)) {
$sql = 'SELECT ResourceId
- FROM '.$this->Application->getUnitOption('fav', 'TableName').'
+ FROM ' . $this->Application->getUnitConfig('fav')->getTableName() . '
WHERE PortalUserId = '.$this->Application->RecallVar('user_id');
$favorite_ids = $this->Conn->GetCol($sql);
+
if ($favorite_ids) {
$type_clauses['favorites']['include'] = '%1$s.ResourceId IN ('.implode(',', $favorite_ids).') AND PrimaryCat = 1';
$type_clauses['favorites']['except'] = '%1$s.ResourceId NOT IN ('.implode(',', $favorite_ids).') AND PrimaryCat = 1';
@@ -554,6 +560,7 @@
$type_clauses['favorites']['include'] = 0;
$type_clauses['favorites']['except'] = 1;
}
+
$type_clauses['favorites']['having_filter'] = false;
}
@@ -685,7 +692,7 @@
function applyItemStatusFilter(&$object, $types)
{
// Link1 (before modifications) [Status = 1, OrgId = NULL], Link2 (after modifications) [Status = -2, OrgId = Link1_ID]
- $pending_editing = $this->Application->getUnitOption($object->Prefix, 'UsePendingEditing');
+ $pending_editing = $object->getUnitConfig()->getUsePendingEditing();
if (!$this->Application->isAdminUser) {
$types = explode(',', $types);
@@ -765,17 +772,15 @@
function prepareItemStatuses($event)
{
$object = $event->getObject( Array('skip_autoload' => true) );
+ $property_map = $event->getUnitConfig()->getItemPropertyMappings();
- $property_map = $this->Application->getUnitOption($event->Prefix, 'ItemPropertyMappings');
if (!$property_map) {
return ;
}
// new items
$object->addCalculatedField('IsNew', ' IF(%1$s.NewItem = 2,
- IF(%1$s.CreatedOn >= (UNIX_TIMESTAMP() - '.
- $this->Application->ConfigValue($property_map['NewDays']).
- '*3600*24), 1, 0),
+ IF(%1$s.CreatedOn >= (UNIX_TIMESTAMP() - ' . $this->Application->ConfigValue($property_map['NewDays']) . '*3600*24), 1, 0),
%1$s.NewItem
)');
@@ -799,11 +804,7 @@
// popular items
$object->addCalculatedField('IsPop', ' IF(%1$s.PopItem = 2,
- IF(%1$s.CachedVotesQty >= '.
- $this->Application->ConfigValue($property_map['MinPopVotes']).
- ' AND %1$s.CachedRating >= '.
- $this->Application->ConfigValue($property_map['MinPopRating']).
- ', 1, 0),
+ IF(%1$s.CachedVotesQty >= ' . $this->Application->ConfigValue($property_map['MinPopVotes']) . ' AND %1$s.CachedRating >= ' . $this->Application->ConfigValue($property_map['MinPopRating']) . ', 1, 0),
%1$s.PopItem)');
}
@@ -817,7 +818,8 @@
*/
protected function CalculateHotLimit($event)
{
- $property_map = $this->Application->getUnitOption($event->Prefix, 'ItemPropertyMappings');
+ $config = $event->getUnitConfig();
+ $property_map = $config->getItemPropertyMappings();
if ( !$property_map ) {
return 0.00;
@@ -827,7 +829,7 @@
$last_hot = $this->Application->ConfigValue($property_map['MaxHotNumber']) - 1;
$sql = 'SELECT ' . $click_field . '
- FROM ' . $this->Application->getUnitOption($event->Prefix, 'TableName') . '
+ FROM ' . $config->getTableName() . '
ORDER BY ' . $click_field . ' DESC
LIMIT ' . $last_hot . ', 1';
$res = $this->Conn->GetCol($sql);
@@ -859,13 +861,15 @@
/* @var $object kCatDBItem */
// update hits field
- $property_map = $this->Application->getUnitOption($event->Prefix, 'ItemPropertyMappings');
+ $config = $event->getUnitConfig();
+ $property_map = $config->getUserProfileMapping();
+
if ( $property_map ) {
$click_field = $property_map['ClickField'];
if ( $this->Application->isAdminUser && ($this->Application->GetVar($click_field . '_original') !== false) && floor($this->Application->GetVar($click_field . '_original')) != $object->GetDBField($click_field) ) {
$sql = 'SELECT MAX(' . $click_field . ')
- FROM ' . $this->Application->getUnitOption($event->Prefix, 'TableName') . '
+ FROM ' . $config->getTableName() . '
WHERE FLOOR(' . $click_field . ') = ' . $object->GetDBField($click_field);
$hits = ($res = $this->Conn->GetOne($sql)) ? $res + 0.000001 : $object->GetDBField($click_field);
@@ -875,6 +879,7 @@
// change category
$target_category = $object->GetDBField('CategoryId');
+
if ( $object->GetOriginalField('CategoryId') != $target_category ) {
$object->MoveToCat($target_category);
}
@@ -995,7 +1000,7 @@
if ( $this->Application->isAdminUser && $recycle_bin ) {
$sql = 'SELECT CategoryId
- FROM ' . $this->Application->getUnitOption('ci', 'TableName') . '
+ FROM ' . $this->Application->getUnitConfig('ci')->getTableName() . '
WHERE ItemResourceId = ' . $object->GetDBField('ResourceId') . ' AND PrimaryCat = 1';
$primary_category = $this->Conn->GetOne($sql);
@@ -1116,13 +1121,15 @@
$object = $event->getObject();
/* @var $object kDBList */
+ $config = $event->getUnitConfig();
+
$this->Application->SetVar($event->getPrefixSpecial().'_Page', 1);
$lang = $this->Application->GetVar('m_lang');
- $items_table = $this->Application->getUnitOption($event->Prefix, 'TableName');
+ $items_table = $config->getTableName();
$module_name = $this->Application->findModule('Var', $event->Prefix, 'Name');
$sql = 'SELECT *
- FROM ' . $this->Application->getUnitOption('confs', 'TableName') . '
+ FROM ' . $this->Application->getUnitConfig('confs')->getTableName() . '
WHERE ModuleName = ' . $this->Conn->qstr($module_name) . ' AND SimpleSearch = 1';
$search_config = $this->Conn->Query($sql, 'FieldName');
@@ -1135,9 +1142,9 @@
$alias_counter = 0;
- $custom_fields = $this->Application->getUnitOption($event->Prefix, 'CustomFields');
+ $custom_fields = $config->getCustomFields();
if ($custom_fields) {
- $custom_table = $this->Application->getUnitOption($event->Prefix.'-cdata', 'TableName');
+ $custom_table = $this->Application->getUnitConfig($event->Prefix . '-cdata')->getTableName();
$join_clauses[] = ' LEFT JOIN '.$custom_table.' custom_data ON '.$items_table.'.ResourceId = custom_data.ResourceId';
}
@@ -1276,7 +1283,7 @@
// making relevance clause
$positive_words = $search_helper->getPositiveKeywords($keywords);
$this->Application->StoreVar('highlight_keywords', serialize($positive_words));
- $revelance_parts = Array();
+ $relevance_parts = Array();
reset($search_config);
foreach ($positive_words as $keyword_index => $positive_word) {
@@ -1297,25 +1304,25 @@
$weight = $config_elem['Priority'];
// search by whole words only ([[:<:]] - word boundary)
- /*$revelance_parts[] = 'IF('.$field.' REGEXP "[[:<:]]('.implode(' ', $positive_words).')[[:>:]]", '.$weight.', 0)';
+ /*$relevance_parts[] = 'IF('.$field.' REGEXP "[[:<:]]('.implode(' ', $positive_words).')[[:>:]]", '.$weight.', 0)';
foreach ($positive_words as $keyword) {
- $revelance_parts[] = 'IF('.$field.' REGEXP "[[:<:]]('.$keyword.')[[:>:]]", '.$weight.', 0)';
+ $relevance_parts[] = 'IF('.$field.' REGEXP "[[:<:]]('.$keyword.')[[:>:]]", '.$weight.', 0)';
}*/
// search by partial word matches too
- $revelance_parts[] = 'IF('.$field.' LIKE "%'.implode(' ', $positive_words).'%", '.$weight_sum.', 0)';
+ $relevance_parts[] = 'IF('.$field.' LIKE "%'.implode(' ', $positive_words).'%", '.$weight_sum.', 0)';
foreach ($positive_words as $keyword) {
- $revelance_parts[] = 'IF('.$field.' LIKE "%'.$keyword.'%", '.$weight.', 0)';
+ $relevance_parts[] = 'IF('.$field.' LIKE "%'.$keyword.'%", '.$weight.', 0)';
}
}
- $revelance_parts = array_unique($revelance_parts);
+ $relevance_parts = array_unique($relevance_parts);
- $conf_postfix = $this->Application->getUnitOption($event->Prefix, 'SearchConfigPostfix');
+ $conf_postfix = $config->getSearchConfigPostfix();
$rel_keywords = $this->Application->ConfigValue('SearchRel_Keyword_'.$conf_postfix) / 100;
$rel_pop = $this->Application->ConfigValue('SearchRel_Pop_'.$conf_postfix) / 100;
$rel_rating = $this->Application->ConfigValue('SearchRel_Rating_'.$conf_postfix) / 100;
- $relevance_clause = '('.implode(' + ', $revelance_parts).') / '.$weight_sum.' * '.$rel_keywords;
+ $relevance_clause = '('.implode(' + ', $relevance_parts).') / '.$weight_sum.' * '.$rel_keywords;
if ($rel_pop && $object->isField('Hits')) {
$relevance_clause .= ' + (Hits + 1) / (MAX(Hits) + 1) * '.$rel_pop;
}
@@ -1337,17 +1344,17 @@
$select_intro = 'CREATE TABLE '.$search_table.' AS ';
}
- $edpick_clause = $this->Application->getUnitOption($event->Prefix.'.EditorsPick', 'Fields') ? $items_table.'.EditorsPick' : '0';
+ $edpick_clause = $config->getFieldByName('EditorsPick') ? $items_table.'.EditorsPick' : '0';
$sql = $select_intro.' SELECT '.$relevance_clause.' AS Relevance,
- '.$items_table.'.'.$this->Application->getUnitOption($event->Prefix, 'IDField').' AS ItemId,
+ '.$items_table.'.'.$config->getIDField().' AS ItemId,
'.$items_table.'.ResourceId,
- '.$this->Application->getUnitOption($event->Prefix, 'ItemType').' AS ItemType,
+ '.$config->getItemType().' AS ItemType,
'.$edpick_clause.' AS EdPick
FROM '.$object->TableName.'
'.implode(' ', $join_clauses).'
WHERE '.$where_clause.'
- GROUP BY '.$items_table.'.'.$this->Application->getUnitOption($event->Prefix, 'IDField').' ORDER BY Relevance DESC';
+ GROUP BY '.$items_table.'.'.$config->getIDField().' ORDER BY Relevance DESC';
$this->Conn->Query($sql);
@@ -1374,7 +1381,7 @@
$sql = 'SHOW TABLES LIKE "' . $search_table . '"';
if ( $this->Conn->Query($sql) ) {
- $item_type = $this->Application->getUnitOption($event->Prefix, 'ItemType');
+ $item_type = $event->getUnitConfig()->getItemType();
// 1. get ids to be used as search bounds
$sql = 'SELECT DISTINCT ResourceId
@@ -1414,7 +1421,7 @@
$module_name = $this->Application->findModule('Var', $event->Prefix, 'Name');
$sql = 'SELECT *
- FROM '.$this->Application->getUnitOption('confs', 'TableName').'
+ FROM '.$this->Application->getUnitConfig('confs')->getTableName().'
WHERE (ModuleName = '.$this->Conn->qstr($module_name).') AND (AdvancedSearch = 1)';
$search_config = $this->Conn->Query($sql);
@@ -1425,7 +1432,8 @@
$object->SetPage(1);
- $items_table = $this->Application->getUnitOption($event->Prefix, 'TableName');
+ $config = $event->getUnitConfig();
+ $items_table = $config->getTableName();
$search_keywords = $this->Application->GetVar('value'); // will not be changed
@@ -1443,9 +1451,9 @@
$alias_counter = 0;
- $custom_fields = $this->Application->getUnitOption($event->Prefix, 'CustomFields');
+ $custom_fields = $config->getCustomFields();
if ($custom_fields) {
- $custom_table = $this->Application->getUnitOption($event->Prefix.'-cdata', 'TableName');
+ $custom_table = $this->Application->getUnitConfig($event->Prefix . '-cdata')->getTableName();
$join_clauses[] = ' LEFT JOIN '.$custom_table.' custom_data ON '.$items_table.'.ResourceId = custom_data.ResourceId';
}
@@ -1567,7 +1575,7 @@
// making relevance clause
if($relevance_parts)
{
- $conf_postfix = $this->Application->getUnitOption($event->Prefix, 'SearchConfigPostfix');
+ $conf_postfix = $config->getSearchConfigPostfix();
$rel_keywords = $this->Application->ConfigValue('SearchRel_Keyword_'.$conf_postfix) / 100;
$rel_pop = $this->Application->ConfigValue('SearchRel_Pop_'.$conf_postfix) / 100;
$rel_rating = $this->Application->ConfigValue('SearchRel_Rating_'.$conf_postfix) / 100;
@@ -1614,9 +1622,8 @@
$this->Conn->Query('DROP TABLE IF EXISTS '.$search_table);
- $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField');
- $fields = $this->Application->getUnitOption($event->Prefix, 'Fields');
- $pick_field = isset($fields['EditorsPick']) ? $items_table.'.EditorsPick' : '0';
+ $id_field = $config->getIDField();
+ $pick_field = $config->getFieldByName('EditorsPick') ? $items_table.'.EditorsPick' : '0';
$sql = ' CREATE TABLE '.$search_table.'
SELECT '.$relevance_clause.' AS Relevance,
@@ -1680,8 +1687,9 @@
case 'boolean':
if ($keywords[$field] != -1) {
- $property_mappings = $this->Application->getUnitOption($this->Prefix, 'ItemPropertyMappings');
- $items_table = $this->Application->getUnitOption($this->Prefix, 'TableName');
+ $config = $this->getUnitConfig();
+ $items_table = $config->getTableName();
+ $property_mappings = $config->getItemPropertyMappings();
switch ($field) {
case 'HotItem':
@@ -2175,6 +2183,21 @@
/* @var $object kDBItem */
$object->SetDBField($cached_field, $object->GetField($id_field));
+ $options = $object->GetFieldOptions($id_field);
+
+ if ( isset($options['options'][$user_id]) ) {
+ $object->SetDBField($cached_field, $options['options'][$user_id]);
+ }
+ else {
+ $user_config = $this->Application->getUnitConfig('u');
+ $id_field = $user_config->getIDField();
+ $table_name = $user_config->getTableName();
+
+ $sql = 'SELECT Username
+ FROM ' . $table_name . '
+ WHERE ' . $id_field . ' = ' . $user_id;
+ $object->SetDBField($cached_field, $this->Conn->GetOne($sql));
+ }
}
/**
@@ -2189,7 +2212,7 @@
{
parent::OnPreSave($event);
- $use_pending_editing = $this->Application->getUnitOption($event->Prefix, 'UsePendingEditing');
+ $use_pending_editing = $event->getUnitConfig()->getUsePendingEditing();
if ( $event->status == kEvent::erSUCCESS && $use_pending_editing ) {
// decision: clone or not clone
@@ -2354,7 +2377,7 @@
*/
function setItemStatusByPermission($event)
{
- $use_pending_editing = $this->Application->getUnitOption($event->Prefix, 'UsePendingEditing');
+ $use_pending_editing = $event->getUnitConfig()->getUsePendingEditing();
if (!$use_pending_editing) {
return ;
@@ -2458,7 +2481,7 @@
*/
protected function OnUpdate(kEvent $event)
{
- $use_pending = $this->Application->getUnitOption($event->Prefix, 'UsePendingEditing');
+ $use_pending = $event->getUnitConfig()->getUsePendingEditing();
if ($this->Application->isAdminUser || !$use_pending) {
parent::OnUpdate($event);
$this->SetFrontRedirectTemplate($event, 'modify');
@@ -2500,7 +2523,7 @@
$object->SetFieldsFromHash($field_values, $this->getRequestProtectedFields($field_values));
// 1a. delete record from CategoryItems (about cloned item) that was automatically created during call of Create method of kCatDBItem
- $ci_table = $this->Application->getUnitOption('ci', 'TableName');
+ $ci_table = $this->Application->getUnitConfig('ci')->getTableName();
$sql = 'DELETE FROM '.$ci_table.'
WHERE ItemResourceId = '.$object->GetDBField('ResourceId').' AND PrimaryCat = 1';
$this->Conn->Query($sql);
@@ -2566,7 +2589,7 @@
$event->SetRedirectParam('opener', 's');
// send email events
- $perm_prefix = $this->Application->getUnitOption($event->Prefix, 'PermItemPrefix');
+ $perm_prefix = $event->getUnitConfig()->getPermItemPrefix();
$owner_field = $this->getOwnerField($event->Prefix);
$owner_id = $object->GetDBField($owner_field);
@@ -2745,14 +2768,13 @@
*/
protected function _removeForcedSortings(kEvent $event)
{
- $list_sortings = $this->Application->getUnitOption($event->Prefix, 'ListSortings', Array ());
- /* @var $list_sortings Array */
+ $config = $event->getUnitConfig();
- foreach ($list_sortings as $special => $sortings) {
- unset($list_sortings[$special]['ForcedSorting']);
+ foreach ($config->getListSortingSpecials() as $special) {
+ $list_sortings = $config->getListSortingsBySpecial($special);
+ unset($list_sortings['ForcedSorting']);
+ $config->setListSortingsBySpecial('', $list_sortings);
}
-
- $this->Application->setUnitOption($event->Prefix, 'ListSortings', $list_sortings);
}
/**
@@ -2795,7 +2817,7 @@
*/
protected function getOwnerField($prefix)
{
- return $this->Application->getUnitOption($prefix, 'OwnerField', 'CreatedById');
+ return $this->Application->getUnitConfig($prefix)->getOwnerField('CreatedById');
}
/**
@@ -2824,34 +2846,32 @@
$this->changeSortings($event);
// add grids for advanced view (with primary category column)
- $grids = $this->Application->getUnitOption($this->Prefix, 'Grids');
- $process_grids = Array ('Default', 'Radio');
- foreach ($process_grids as $process_grid) {
- $grid_data = $grids[$process_grid];
+ $config = $event->getUnitConfig();
+
+ foreach (Array ('Default', 'Radio') as $process_grid) {
+ $grid_data = $config->getGridByName($process_grid);
$grid_data['Fields']['CachedNavbar'] = Array ('title' => 'la_col_Path', 'data_block' => 'grid_primary_category_td', 'filter_block' => 'grid_like_filter');
- $grids[$process_grid . 'ShowAll'] = $grid_data;
+ $config->addGrids($grid_data, $process_grid . 'ShowAll');
}
- $this->Application->setUnitOption($this->Prefix, 'Grids', $grids);
// add options for CategoryId field (quick way to select item's primary category)
$category_helper = $this->Application->recallObject('CategoryHelper');
/* @var $category_helper CategoryHelper */
- $virtual_fields = $this->Application->getUnitOption($event->Prefix, 'VirtualFields');
-
+ $virtual_fields = $config->getVirtualFields();
$virtual_fields['CategoryId']['default'] = (int)$this->Application->GetVar('m_cat_id');
$virtual_fields['CategoryId']['options'] = $category_helper->getStructureTreeAsOptions();
-
- $this->Application->setUnitOption($event->Prefix, 'VirtualFields', $virtual_fields);
+ $config->setVirtualFields($virtual_fields);
}
- function changeSortings($event)
+ function changeSortings(kEvent $event)
{
$remove_sortings = Array ();
+ $config = $event->getUnitConfig();
if ( !$this->Application->isAdmin ) {
// remove Pick sorting on Front-end, when not required
- $config_mapping = $this->Application->getUnitOption($event->Prefix, 'ConfigMapping', Array ());
+ $config_mapping = $config->getConfigMapping(Array ());
if ( !isset($config_mapping['ForceEditorPick']) || !$this->Application->ConfigValue($config_mapping['ForceEditorPick']) ) {
$remove_sortings[] = 'EditorsPick';
@@ -2866,16 +2886,15 @@
return;
}
- $list_sortings = $this->Application->getUnitOption($event->Prefix, 'ListSortings', Array ());
- /* @var $list_sortings Array */
+ foreach ($config->getListSortingSpecials() as $special) {
+ $list_sortings = $config->getListSortingsBySpecial($special);
- foreach ($list_sortings as $special => $sorting_fields) {
foreach ($remove_sortings as $sorting_field) {
- unset($list_sortings[$special]['ForcedSorting'][$sorting_field]);
+ unset($list_sortings['ForcedSorting'][$sorting_field]);
}
- }
- $this->Application->setUnitOption($event->Prefix, 'ListSortings', $list_sortings);
+ $config->setListSortingsBySpecial('', $list_sortings);
+ }
}
/**
@@ -2952,9 +2971,11 @@
$spam_helper->InitHelper($review_id, 'ReviewHelpful', strtotime('+1 month') - strtotime('now'));
$field = (int)$this->Application->GetVar('helpful') ? 'HelpfulCount' : 'NotHelpfulCount';
+ $review_config = $this->Application->getUnitConfig('rev');
+
$sql = 'SELECT ' . $field . '
- FROM ' . $this->Application->getUnitOption('rev', 'TableName') . '
- WHERE ' . $this->Application->getUnitOption('rev', 'IDField') . ' = ' . $review_id;
+ FROM ' . $review_config->getTableName() . '
+ WHERE ' . $review_config->getIDField() . ' = ' . $review_id;
$count = $this->Conn->GetOne($sql);
if ( $spam_helper->InSpamControl() ) {
@@ -2965,9 +2986,9 @@
return;
}
- $sql = 'UPDATE ' . $this->Application->getUnitOption('rev', 'TableName') . '
+ $sql = 'UPDATE ' . $review_config->getTableName() . '
SET ' . $field . ' = ' . $field . ' + 1
- WHERE ' . $this->Application->getUnitOption('rev', 'IDField') . ' = ' . $review_id;
+ WHERE ' . $review_config->getIDField() . ' = ' . $review_id;
$this->Conn->Query($sql);
if ( $this->Conn->getAffectedRows() ) {
@@ -2992,13 +3013,15 @@
parent::OnCloneSubItem($event);
if ( $event->MasterEvent->Prefix == 'fav' ) {
- $clones = $this->Application->getUnitOption($event->MasterEvent->Prefix, 'Clones');
- $subitem_prefix = $event->Prefix . '-' . $event->MasterEvent->Prefix;
+ $master_config = $event->MasterEvent->getUnitConfig();
- $clones[$subitem_prefix]['ParentTableKey'] = 'ResourceId';
- $clones[$subitem_prefix]['ForeignKey'] = 'ResourceId';
+ $clones = $master_config->getClones();
+ $sub_item_prefix = $event->Prefix . '-' . $event->MasterEvent->Prefix;
- $this->Application->setUnitOption($event->MasterEvent->Prefix, 'Clones', $clones);
+ $clones[$sub_item_prefix]['ParentTableKey'] = 'ResourceId';
+ $clones[$sub_item_prefix]['ForeignKey'] = 'ResourceId';
+
+ $master_config->setClones($clones);
}
}