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.'