Index: branches/5.3.x/units/private_messages/private_message_eh.php =================================================================== diff -u -N -r15670 -r15694 --- branches/5.3.x/units/private_messages/private_message_eh.php (.../private_message_eh.php) (revision 15670) +++ branches/5.3.x/units/private_messages/private_message_eh.php (.../private_message_eh.php) (revision 15694) @@ -1,6 +1,6 @@ getObject(); /* @var $object kDBItem */ - $body_idfield = $this->Application->getUnitOption($event->Prefix . '-body', 'IDField'); - $body_table = $this->Application->getUnitOption($event->Prefix . '-body', 'TableName'); + $config = $this->Application->getUnitConfig($event->Prefix . '-body'); - $sql = 'UPDATE ' . $body_table . ' + $sql = 'UPDATE ' . $config->getTableName() . ' SET ReferenceCount = ReferenceCount - 1 - WHERE ' . $body_idfield . ' = ' . $object->GetDBField('PMBodyId'); + WHERE ' . $config->getIDField() . ' = ' . $object->GetDBField('PMBodyId'); $this->Conn->Query($sql); } @@ -237,11 +236,13 @@ { parent::OnAfterConfigRead($event); - $virtual_fields = $this->Application->getUnitOption($event->Prefix, 'VirtualFields'); + $config = $event->getUnitConfig(); + + $virtual_fields = $config->getVirtualFields(); $virtual_fields['DisableBBCodes']['default'] = (int)!$this->Application->RecallPersistentVar('bbcode'); $virtual_fields['DisableSmileys']['default'] = (int)!$this->Application->RecallPersistentVar('smileys'); $virtual_fields['ShowSignatures']['default'] = (int)$this->Application->RecallPersistentVar('show_sig'); - $this->Application->setUnitOption($event->Prefix, 'VirtualFields', $virtual_fields); + $config->setVirtualFields($virtual_fields); } /** Index: branches/5.3.x/units/posts/post_tp.php =================================================================== diff -u -N -r15490 -r15694 --- branches/5.3.x/units/posts/post_tp.php (.../post_tp.php) (revision 15490) +++ branches/5.3.x/units/posts/post_tp.php (.../post_tp.php) (revision 15694) @@ -1,6 +1,6 @@ Application->getUnitOption($this->Prefix, 'ParentPrefix'); + $parent_prefix = $this->getUnitConfig()->getParentPrefix(); + $main_object = $this->Application->recallObject($parent_prefix); /* @var $main_object kCatDBItem */ @@ -253,7 +254,8 @@ if (!isset($category_path)) { // get topic category - $parent_prefix = $this->Application->getUnitOption($this->Prefix, 'ParentPrefix'); + $parent_prefix = $this->getUnitConfig()->getParentPrefix(); + $parent_item = $this->Application->recallObject($parent_prefix, null, Array ('raise_warnings' => 0)); $category_path = $parent_item->isLoaded() ? $parent_item->GetDBField('ParentPath') : $this->Application->GetVar('m_cat_id'); } Index: branches/5.3.x/install/upgrades.php =================================================================== diff -u -N -r15670 -r15694 --- branches/5.3.x/install/upgrades.php (.../upgrades.php) (revision 15670) +++ branches/5.3.x/install/upgrades.php (.../upgrades.php) (revision 15694) @@ -1,6 +1,6 @@ Application->getUnitConfig('c'); $root_category = $this->Application->findModule('Name', 'In-Bulletin', 'RootCat'); - $sql = 'UPDATE ' . $this->Application->getUnitOption('c', 'TableName') . ' + $sql = 'UPDATE ' . $categories_config->getTableName() . ' SET UseMenuIconUrl = 1, MenuIconUrl = "in-bulletin/img/menu_topics.gif" - WHERE ' . $this->Application->getUnitOption('c', 'IDField') . ' = ' . $root_category; + WHERE ' . $categories_config->getIDField() . ' = ' . $root_category; $this->Conn->Query($sql); $this->_updateDetailTemplate('bb', 'inbulletin/post_list', 'in-bulletin/designs/detail'); Index: branches/5.3.x/units/helpers/post_helper.php =================================================================== diff -u -N -r15670 -r15694 --- branches/5.3.x/units/helpers/post_helper.php (.../post_helper.php) (revision 15670) +++ branches/5.3.x/units/helpers/post_helper.php (.../post_helper.php) (revision 15694) @@ -1,6 +1,6 @@ Application->getUnitOption('c', 'IDField'); - $table_name = $this->Application->getUnitOption('c', 'TableName'); + * @return void + * @param int $date + * @desc Set any field to category & all it's parent categories + */ + function PropagateCategoryField($category_id, $field_name, $field_value) + { + $categories_config = $this->Application->getUnitConfig('c'); + $id_field = $categories_config->getIDField(); + $table_name = $categories_config->getTableName(); - $sql = 'SELECT ParentPath - FROM ' . $table_name . ' - WHERE ' . $id_field . ' = ' . $category_id; - $parent_path = $this->Conn->GetOne($sql); + $sql = 'SELECT ParentPath + FROM ' . $table_name . ' + WHERE ' . $id_field . ' = ' . $category_id; + $parent_path = $this->Conn->GetOne($sql); - $parent_categories = explode('|', substr($parent_path, 1, -1)); - if ( !$parent_categories ) { - return; - } + $parent_categories = explode('|', substr($parent_path, 1, -1)); + if ( !$parent_categories ) { + return; + } - $fields_hash = Array ($field_name => $field_value); + $fields_hash = Array ($field_name => $field_value); - $this->Conn->doUpdate($fields_hash, $table_name, $id_field . ' IN (' . implode(',', $parent_categories) . ')'); - } + $this->Conn->doUpdate($fields_hash, $table_name, $id_field . ' IN (' . implode(',', $parent_categories) . ')'); + } /** * Sets today posts count & today date for topic @@ -132,8 +133,9 @@ function updatePostCount($topic_id, $increment = 1) { - $id_field = $this->Application->getUnitOption('bb', 'IDField'); - $table_name = $this->Application->getUnitOption('bb', 'TableName'); + $topics_config = $this->Application->getUnitConfig('bb'); + $id_field = $topics_config->getIDField(); + $table_name = $topics_config->getTableName(); // helps in case, when 2 (or more) users tries to post in same topic at same time $sql = 'UPDATE '.$table_name.' Index: branches/5.3.x/units/topics/topics_event_handler.php =================================================================== diff -u -N -r15490 -r15694 --- branches/5.3.x/units/topics/topics_event_handler.php (.../topics_event_handler.php) (revision 15490) +++ branches/5.3.x/units/topics/topics_event_handler.php (.../topics_event_handler.php) (revision 15694) @@ -1,6 +1,6 @@ Application->getUnitOption($event->Prefix, 'Fields'); + $config = $event->getUnitConfig(); + + $fields = $config->getFields(); $fields['NotifyOwnerOnChanges']['default'] = (int)$this->Application->RecallPersistentVar('owner_notify'); - $this->Application->setUnitOption($event->Prefix, 'Fields', $fields); + $config->setFields($fields); - $virtual_fields = $this->Application->getUnitOption($event->Prefix, 'VirtualFields'); + $virtual_fields = $config->getVirtualFields(); $virtual_fields['DisableBBCodes']['default'] = (int)!$this->Application->RecallPersistentVar('bbcode'); $virtual_fields['DisableSmileys']['default'] = (int)!$this->Application->RecallPersistentVar('smileys'); $virtual_fields['ShowSignatures']['default'] = (int)$this->Application->RecallPersistentVar('show_sig'); - $this->Application->setUnitOption($event->Prefix, 'VirtualFields', $virtual_fields); + $config->setVirtualFields($virtual_fields); } /** @@ -240,17 +242,18 @@ parent::OnCloneSubItem($event); if ( $event->MasterEvent->Prefix == 'rev' ) { - $clones = $this->Application->getUnitOption($event->MasterEvent->Prefix, 'Clones'); - $subitem_prefix = $event->Prefix . '-' . $event->MasterEvent->Prefix; + $sub_item_prefix = $event->Prefix . '-' . $event->MasterEvent->Prefix; - $clones[$subitem_prefix]['ConfigMapping'] = Array ( - 'PerPage' => 'Perpage_TopicReviews', + $event->MasterEvent->getUnitConfig()->addClones(Array ( + $sub_item_prefix => Array ( + 'ConfigMapping' => Array ( + 'PerPage' => 'Perpage_TopicReviews', - 'ReviewDelayInterval' => 'topic_ReviewDelay_Interval', - 'ReviewDelayValue' => 'topic_ReviewDelay_Value', - ); - - $this->Application->setUnitOption($event->MasterEvent->Prefix, 'Clones', $clones); + 'ReviewDelayInterval' => 'topic_ReviewDelay_Interval', + 'ReviewDelayValue' => 'topic_ReviewDelay_Value', + ) + ), + )); } } Index: branches/5.3.x/units/posts/post_eh.php =================================================================== diff -u -N -r15670 -r15694 --- branches/5.3.x/units/posts/post_eh.php (.../post_eh.php) (revision 15670) +++ branches/5.3.x/units/posts/post_eh.php (.../post_eh.php) (revision 15694) @@ -1,6 +1,6 @@ getObject(); /* @var $object kDBItem */ - $parent_prefix = $this->Application->getUnitOption($event->Prefix, 'ParentPrefix'); + $parent_prefix = $event->getUnitConfig()->getParentPrefix(); $main_object = $this->Application->recallObject($parent_prefix); /* @var $main_object kCatDBItem */ @@ -394,11 +394,13 @@ { parent::OnAfterConfigRead($event); - $virtual_fields = $this->Application->getUnitOption($event->Prefix, 'VirtualFields'); + $config = $event->getUnitConfig(); + + $virtual_fields = $config->getVirtualFields(); $virtual_fields['DisableBBCodes']['default'] = (int)!$this->Application->RecallPersistentVar('bbcode'); $virtual_fields['DisableSmileys']['default'] = (int)!$this->Application->RecallPersistentVar('smileys'); $virtual_fields['ShowSignatures']['default'] = (int)$this->Application->RecallPersistentVar('show_sig'); - $this->Application->setUnitOption($event->Prefix, 'VirtualFields', $virtual_fields); + $config->setVirtualFields($virtual_fields); } /** @@ -413,7 +415,7 @@ parent::OnDelete($event); if ( $event->status == kEvent::erSUCCESS && !$this->Application->isAdmin ) { - $parent_prefix = $this->Application->getUnitOption($event->Prefix, 'ParentPrefix'); + $parent_prefix = $event->getUnitConfig()->getParentPrefix(); $event->SetRedirectParam('pass', 'm,' . $parent_prefix); } } Index: branches/5.3.x/units/poll_comments/poll_comment_eh.php =================================================================== diff -u -N -r15670 -r15694 --- branches/5.3.x/units/poll_comments/poll_comment_eh.php (.../poll_comment_eh.php) (revision 15670) +++ branches/5.3.x/units/poll_comments/poll_comment_eh.php (.../poll_comment_eh.php) (revision 15694) @@ -1,6 +1,6 @@ Application->RecallVar('user_id') == USER_GUEST ) { // make Guest Name and Email required for guests - $fields = $this->Application->getUnitOption($event->Prefix, 'Fields'); + $config = $event->getUnitConfig(); + + $fields = $config->getFields(); $fields['GuestName']['required'] = 1; $fields['GuestEmail']['required'] = 1; - $this->Application->setUnitOption($event->Prefix, 'Fields', $fields); + $config->setFields($fields); } } Index: branches/5.3.x/units/polls/poll_eh.php =================================================================== diff -u -N -r15670 -r15694 --- branches/5.3.x/units/polls/poll_eh.php (.../poll_eh.php) (revision 15670) +++ branches/5.3.x/units/polls/poll_eh.php (.../poll_eh.php) (revision 15694) @@ -1,6 +1,6 @@ Conn->Query($sql); - $poll_answers_table = $this->Application->getUnitOption('poll-answer', 'TableName'); + $poll_answers_table = $this->Application->getUnitConfig('poll-answer')->getTableName(); $poll_answers_table = $this->Application->GetTempName($poll_answers_table); - $sql = 'UPDATE '.$poll_answers_table.' SET VotesQty = 0 - WHERE '.$object->IDField.' = '.$object->GetID(); + $sql = 'UPDATE '.$poll_answers_table.' + SET VotesQty = 0 + WHERE '.$object->IDField.' = '.$object->GetID(); $this->Conn->Query($sql); } @@ -137,15 +138,22 @@ $this->Conn->doInsert($fields_hash, TABLE_PREFIX.'PollsStatistics'); - $poll_table = $this->Application->getUnitOption('poll', 'TableName'); - $this->Conn->Query('UPDATE '.$poll_table.' SET CachedVotesQty = CachedVotesQty + 1 - WHERE PollId = '.$object->GetID()); + $poll_table = $this->Application->getUnitConfig('poll')->getTableName(); + $sql = 'UPDATE ' . $poll_table . ' + SET CachedVotesQty = CachedVotesQty + 1 + WHERE PollId = ' . $object->GetID(); + $this->Conn->Query($sql); + // update table with answers - $poll_answers_table = $this->Application->getUnitOption('poll-answer', 'TableName'); - $this->Conn->Query('UPDATE '.$poll_answers_table.' SET VotesQty = VotesQty + 1 - WHERE PollId = '.$object->GetID().' AND AnswerId = '.$poll_answer_id); + $poll_answers_table = $this->Application->getUnitConfig('poll-answer')->getTableName(); + + $sql = 'UPDATE ' . $poll_answers_table . ' + SET VotesQty = VotesQty + 1 + WHERE PollId = ' . $object->GetID() . ' AND AnswerId = ' . $poll_answer_id; + $this->Conn->Query($sql); } + $event->setEventParam('PollId', $this->Application->GetVar('poll_id')); $event->redirect = false; }